Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.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变量_Php - Fatal编程技术网

如何在双引号php字符串中插入php变量

如何在双引号php字符串中插入php变量,php,Php,如何在html字符串中插入php变量?我试着这样做,但它跑不动。请参考下面的代码 <?php $a['id'] = 1; $html .= '<a href="{$a['id']}">Link</a>'; ?> 您错过了结账”。此外,还需要使用PHP连接运算符连接字符串和变量: $a['id'] = 1; $html .= '<a href="' . $a['id'] . '">Link</a>'; $a['id']=1;

如何在html字符串中插入php变量?我试着这样做,但它跑不动。请参考下面的代码

<?php 
  $a['id'] = 1;
  $html .= '<a href="{$a['id']}">Link</a>';
?>

您错过了结账
。此外,还需要使用PHP连接运算符
连接字符串和变量:

$a['id'] = 1;
$html .= '<a href="' . $a['id'] . '">Link</a>';
$a['id']=1;
$html.='';

如何修复打字错误<代码>$a['id']=1修复输入错误。连接变量,或者使用双引号并转义用于属性封装的变量。以上只是一个示例。如果我想
echo
在一个双涂层字符串中回送该变量,该怎么办@达戈尼现在编辑,很抱歉我错过了这个问题,因为这是一个懒惰的问题,用任何搜索引擎都可以轻松回答。谢谢你的快速回复answer@claudios不客气