close

[php]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;
?>


arrow
arrow
    全站熱搜

    stockwfj3 發表在 痞客邦 留言(0) 人氣()