<?php
print "print does not require parentheses.";
// 不会新增新行或者空格;下面会在一行中输出“helloworld”
print "hello";
print "world";
print "This string spans
multiple lines. The newlines will be
output as well";
print "This string spans\nmultiple lines. The newlines will be\noutput as well.";
// 参数可以是任何生成字符串的表达式
$foo = "example";
print "foo is $foo"; // foo is example
$fruits = ["lemon", "orange", "banana"];
print implode(" and ", $fruits); // lemon and orange and banana
// 即使使用了 declare(strict_types=1),非字符串表达式也会强制转换为字符串
print 6 * 7; // 42
// 因为 print 有返回值,所以可以在如下表达式中使用
// 以下输出“hello world”
if ( print "hello" ) {
echo " world";
}
// 以下输出“true”
( 1 === 1 ) ? print 'true' : print 'false';
?>