开发者

PHP echo does not work

开发者 https://www.devze.com 2023-01-16 01:16 出处:网络
I am trying to print a variable between curly braces as 开发者_如何学PythonProduct_number{product_version}

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

精彩评论

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

关注公众号