开发者

PHP echo does not work

I am trying to print a variable between curly braces as

开发者_如何学Python
Product_number{product_version}

I tried

echo "$product_number{$product_version}";

But that does not work. I don't understand why :(


try using double braces:

echo "$product_number{{$product_version}}";

You can also do:

echo "$product_number{".$product_version."}";

{ followed by $ is treated specially. It is mainly used when you want to append a string immediately at the end of a variable's value:

$v = 'hack';
echo "I {$v}ed it";


echo $product_number . "{" . $product_version . "}";


Escape the "{":

echo "$product_number\{$product_version}";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜