以下php脚本打印了几个语句和变量!他们在同一条线上打印!我想一个接一个地分开打印它们!我该怎么做? 例如,前2个语句应打印为:
用PHP编程很有趣
我学会了如何在PHP中发表评论
但目前打印为 PHP编程很有趣我学会了如何在PHP中发表评论
?php
echo "Programming in PHP is fun";
//This is the 1st programming 4 tutorial
/*This tutorial helped me
to gain a good knowledge in php! */
print "I learnt how to comment in PHP";
echo "A variable name must start with a letter or an underscore '_' -- not a number";
echo "A variable name can only contain alpha-numeric characters, underscores (a-z, A-Z, 0-9, and _ )";
echo "A variable name should not contain spaces. If a variable name is more than one word, it should beseparated with an underscore or with capitalization ";
$name= "My name is XXX";
$number=25;
$float_number=10.245;
$negative_number=-12;
echo($name);
echo($number);
echo($float_number);
echo($negative_number);
$age=24;
$feature =$age;
echo($feature);
$x=45;
$y=12;
echo($x+$y);
$myName="My name is 'Lasith'";
?>
答案 0 :(得分:1)
如果您将它们作为纯文本回显,请在每个回显后添加换行符:
echo "\n";
如果您将它们回显到HTML(进入Web浏览器),请在每次回显后添加HTML <br>
标记:
echo "<br>";
您也可以使用字符串连接
echo "Programming in PHP is fun" . "\n";
echo "Programming in PHP is fun" . "<br>";
或将换行符或<br>
标记添加到字符串
echo "Programming in PHP is fun\n";
echo "Programming in PHP is fun<br>";