(PHP 4, PHP 5, PHP 7)
چاپ یک رشته در خروجی
توضیحات
print ( string $arg ) : int
print در واقع یک تابع واقعی نیست (یک ساختار زبان است) بنابراین شما نیازی به استفاده از پرانتز با لیست آرگومان خود ندارید.
تفاوت عمده در پژواک این است که print فقط یک آرگومان را می پذیرد و همیشه 1 را برمی گرداند.
پارامتر ها
arg
پارامتر ورودی
مقادیر خروجی
همیشه 1 برگردانده می شود
مثال
<?php print("Hello World"); print "print() also works without parentheses."; print "This spans multiple lines. The newlines will be output as well"; print "This spans\nmultiple lines. The newlines will be\noutput as well."; print "escaping characters is done \"Like this\"."; // می توانید از متغیرها در داخل دستور چاپ استفاده کنید $foo = "foobar"; $bar = "barbaz"; print "foo is $foo"; // foo برابر با foobar است // همچنین می توانید از آرایه ها استفاده کنید $bar = array("value" => "foo"); print "this is {$bar['value']} !"; // this is foo ! // با استفاده از تک نقل قول ها ، نام متغیر چاپ می شود ، نه مقدار print 'foo is $foo'; // foo is $foo // اگر از کاراکترهای دیگری استفاده نمی کنید ، فقط می توانید متغیرها را چاپ کنید print $foo; // foobar print <<<END This uses the "here document" syntax to output multiple lines with $variable interpolation. Note that the here document terminator must appear on a line with just a semicolon no extra whitespace! END; ?>
- ۹۹/۱۰/۰۸