print

(PHP 4, PHP 5, PHP 7)

print锟斤拷锟斤拷址锟斤拷锟�

说锟斤拷

print ( string $arg ) : int

锟斤拷锟� arg锟斤拷

print 实锟斤拷锟较诧拷锟角猴拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟皆结构锟斤拷锟斤拷锟斤拷锟皆匡拷锟皆诧拷锟斤拷圆锟斤拷锟脚帮拷围锟斤拷锟斤拷锟叫憋拷

锟斤拷 echo 锟斤拷锟斤拷要锟斤拷锟斤拷锟斤拷 print 锟斤拷支锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟角凤拷锟斤拷 1锟斤拷

锟斤拷锟斤拷

arg

锟斤拷锟斤拷锟斤拷锟捷★拷

锟斤拷锟斤拷值

锟斤拷锟角凤拷锟斤拷 1锟斤拷

锟斤拷锟斤拷

Example #1 print 锟斤拷锟斤拷

<?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 is 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;
?>

注锟斤拷

Note: 锟斤拷为锟斤拷一锟斤拷锟斤拷锟皆癸拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟杰憋拷 锟缴变函锟斤拷 锟斤拷锟矫★拷

锟轿硷拷

  • echo - 锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷址锟斤拷锟�
  • printf() - 锟斤拷锟斤拷锟绞斤拷锟斤拷址锟斤拷锟�
  • flush() - 刷锟斤拷锟斤拷锟斤拷锟斤拷锟�
  • Heredoc syntax