我想知道如何在下面的代码中打印出空格。
<?php echo "$first_name", "$last_name" ; ?>
Just, well, add whitespace to your output?
<?php echo "$first_name $last_name with some whitespace" ; ?>
Sometimes, it the obvious answer is right - even in PHP!
如果要连接多个不带双引号的字符串(例如,使用单引号时):
$string = $first_name . ' ' . $last_name; // The dot is a concatenation operator
<?php
echo "$first_name $last_name";
?>
Notice that when you use '
any var aren't display, with "
does.
So, good is:
<?php echo "$first_name $last_name" ; ?>
bad
<?php echo '$first_name $last_name' ; ?>
如果要继续使用逗号:
<?php echo $first_name, ' ', $last_name; ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.