php 有三种输出数据的方式:echo,print,print_r
其中echo可以输出一个或多个字符串;
print 可以输出一个字符串,是一个函数,返回值为1;
print_r 可以输出int,string,数组等复杂变量的值,是一个函数,返回值为true;
以上(echo,print)如果需要输出多个字符串,需要带引号,所有字符串均可以在双引号或者单引号中输入。
print_r则是需要在print_r()形式输出int,string,数组的值;
以上三个均可以输出一个不带引号的随机字符;
<!Doctype>
<html>
<head></head>
<body>
<?php
echo "Hello World\n";
$x=5;
$y=6;
$z=$x+$y;
print "<br/>";
echo "z=$z";
echo "<h4>你好</h4>";
echo "i about learn php<br/>";
echo "zxwo\n","vcbn\n","nbmg\n<br/>";
print "123";
$printreturn=print "nbmg\n<br/>";
echo "print=$printreturn";
$txt1="learn php";
$txt2="w3cschool.com";
$txt3=array("123","456","tyu");
echo $txt1;
echo "<br/>";
echo "i have a dream at $txt2";
echo "<br/>";
echo "txt3[0]={$txt3[0]}";
print "<br/>";
$print2=print $txt1;
print "<br/>";
print "print2=$print2";
print "<br/>";
print "print out array =$txt3";
print "<br/>";
$txt1="learn php";
$txt2="w3cschool.com";
$txt3=array("123","456","tyu");
// print $txt1;
print_r ($txt3);
php?>
<p>
how are you ??<br/>
I'm fine ,thank you!!
</p>
</body>
</html>