Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
连接PHP代码块中的字符串_Php_Concatenation_Heredoc - Fatal编程技术网

连接PHP代码块中的字符串

连接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

我想将一个字符串连接到一个长(ish)的herdoc块中

我正在制作一个非常快速和肮脏的表单生成器,用于在数据库中输入虚拟数据。我在文本块中有
$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" ...