【发布时间】:2016-09-29 13:55:26
【问题描述】:
下面的 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'";
?>
【问题讨论】:
-
使用html
br标签 -
使用
PHP_EOL。example:- echo($x+$y).PHP_EOL; -
对于 html,它是
<br>。对于文本,它是\n或\r\n,它只能在双引号中使用,或者是 PHP_EOL,正如 Anant 建议的那样,它不能在引号内使用。
标签: php printing lines separator