Sai*_*akR -1 php string string-concatenation
For variable $x we can concatenate it to a string in many ways, one of them is like the following:
$x = "Hello";
echo "I say {$x} to all of you.";
// The output should be: I say Hello to all of you.
Run Code Online (Sandbox Code Playgroud)
However, If I tried to do something like this with a function, it will fail:
$x = "Hello";
echo "I say {strtolower($x)} to all of you.";
// The output should be: I say {strtolower(Hello)} to all of you.
Run Code Online (Sandbox Code Playgroud)
If there is a synonym way just like used for the variable, I will be appreciated to know it. In other words, I don't want to split the main string and I don't want to use sprinf.
You can concatenate with . operator:
echo "I say " . strtolower($x) . " to all of you.";
Run Code Online (Sandbox Code Playgroud)
Or just :
echo "I say ", strtolower($x), " to all of you.";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7372 次 |
| 最近记录: |