[英]Using variable in echoed string, how to “end” variable?
where $q is q $ q是q
echo "asd$q";
will output asdq 将输出asdq
echo "asd$q_";
will look for $q_ and since thats null, it will print asd 会寻找$ q_,因为那是null,它将显示asd
to get "asdq_" what should I do ? 得到“ asdq_”我该怎么办?
You can concatenate the variable with the string using .
您可以使用将字符串与变量连接起来.
$q='q';
echo 'asd'.$q.'_';
Do like this.. Enclose the $q
variable under curly braces. 这样做。.将$q
变量括在花括号下。
<?php
$q='q';
echo "asd{$q}_"; //"prints" asdq_
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.