将变量与字符串分开

Tuc*_*uco 0 php

我有2个vars - $ j和$ r

在字符串"$ jx $ r"中,php将$ jx视为变量,但"x"是一个字符串.

edo*_*ian 8

你需要重新格式化你的字符串:

这可能更容易阅读:

echo $j."x".$r
Run Code Online (Sandbox Code Playgroud)

但如果你想要一个字符串:

echo "{$j}x$r";
Run Code Online (Sandbox Code Playgroud)

See the manual page for double quoted strings,还有一个解释花括号如何工作的解释.