In php, there are two basic output methods: echo and print
Difference between echo and print:
echo statement:
Echo is a language structure and can be used with or without parentheses: echo or echo();
For example:
Display string:
echo "
echo "Hello world!";
echo "Plan","Learn","PHP";
?>
Display variables:
$txt1 = "Learn PHP";
$txt2 = "***.com";
$cars = array("Volvo","BWM","AABB");
echo $txt1;
echo "
";
echo "Study PHP at $txt2";
echo "
";
echo "my car is a {$cars[0]}";
?>
Print statement:
Print is also a language structure and can be used with or without parentheses: print or print();
Display string:
print "
print ""Hello world!
";
print "I'm about to learn PHP!";
?>
Display variables:
$txt1="Learn PHP";
$txt2="W3School.com.cn";
$cars=array("Volvo","BMW","SAAB");
print $txt1;
print "
";
print "Study PHP at $txt2";
print "My car is a {$cars[0]}";
?> ;
Okay, that’s all for now. I’ll add more when I think of it. Netizens are welcome to comment! ! ! ! ! !