连接PHP代码块中的字符串
我想将一个字符串连接到一个长(ish)的herdoc块中 我正在制作一个非常快速和肮脏的表单生成器,用于在数据库中输入虚拟数据。我在文本块中有连接PHP代码块中的字符串,php,concatenation,heredoc,Php,Concatenation,Heredoc,我想将一个字符串连接到一个长(ish)的herdoc块中 我正在制作一个非常快速和肮脏的表单生成器,用于在数据库中输入虚拟数据。我在文本块中有$var.Help: $out = <<<textOnly <div class="form-group"> <label for="$var">$var</label> <input type="text" class="form-control" id="$var" ari
$var.Help
:
$out = <<<textOnly
<div class="form-group">
<label for="$var">$var</label>
<input type="text" class="form-control" id="$var" aria-describedby="$var" placeholder="$var">
<small id="$var.Help"
class="form-text text-muted">
We'll never share your email with anyone else.</small>
</div>
textOnly;
在PHP中。然后在行中使用该值
<small id="$var.Help"
{$var}帮助
应该可以做到这一点。您使用{
只需在需要的位置添加字符串您的代码片段将生成一个没有错误的字符串。请使用$var=?显示一个完整的可复制示例,该示例通过相关的错误描述澄清了您的问题或错误。感谢这帮助我改进了问题。好吧,每个人都可能犯错误,但不是每个人都会犯错误你可以用你所拥有的、你想要的和你尝试过的来提出一个好问题,所以你把最难的部分做对了:真正提出一个好问题:D干杯!
<small id="$var.Help"
<small id="fredHelp" ...