如何使用换行标签来回显不止一件事?
我目前正在使用下面的代码来回显一些不同的变量和 2 个换行符。
但我想知道的是如何将所有变量(包括换行符)回显到一行代码中?
<?php
function findworld($var) {
return strpos($var, "world");
}
$firstvar = "hello world";
$secondvar = findworld($firstvar);
$thirdvar = strlen($firstvar);
echo $firstvar;
echo "<br />";
echo $secondvar;
echo "<br />";
echo $thirdvar;
?>
I am currently using the below code to echo a few different variables and 2 line breaks.
But what I would like to know is how can I echo all of the variables including line breaks into one line of code?
<?php
function findworld($var) {
return strpos($var, "world");
}
$firstvar = "hello world";
$secondvar = findworld($firstvar);
$thirdvar = strlen($firstvar);
echo $firstvar;
echo "<br />";
echo $secondvar;
echo "<br />";
echo $thirdvar;
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
php 中的连接运算符是“.”
http://www.php.net/manual/en/language.operators .string.php
the concat operator in php is "."
http://www.php.net/manual/en/language.operators.string.php
您可以将多个参数传递给
echo
,用逗号分隔:为了避免重复换行,您还可以使用
内爆
:You can pass multiple parameters to
echo
, separated by a comma:To avoid repeating the line break, you could also use
implode
:您可以使用字符串连接:
You can use string concatenation:
就像其他人所说的那样,但在所有正确的位置都有语音标记;)
Like others have said, but with speech marks in the all the correct places ;)
您根本不需要用双引号连接,您可以:
You don't need to concatenate at all with double quotes, you can just: