在 php 文件中如何使用 html 引号?

Inside php file how to work with html quotes?

我有这个html:

<button type="button" class="btn-option delete po" data-toggle="popover" data-placement="left" data-content="<a class='btn btn-danger po-delete ajax-silent' href='#'>Yes im sure</a><button class='btn po-close'>No</button> 
<input type='hidden' name='td-id' class='id' value='id'>" data-original-title="<b>Really delete</b>"><i class="fa fa-times"></i></button><a href="url" class="btn-option" data-toggle="mainmodal"><i class="fa fa-cog"></i></a>

我想在 php 文件上打印类似这样的内容:

$a = 数组(); $a["button"] = 'here the html';

但是单引号破坏了我的代码。

在这种情况下我该怎么做?

谢谢

您可以使用 PHP 的连接运算符 (.) 连接它们:

$a["button"] = 
'<button type="button" class="btn-option delete po" data-toggle="popover" data-placement="left" data-content="<a class='
. "'btn btn-danger po-delete ajax-silent' href='#'>Yes im sure</a><button class='btn po-close'>No</button> 
<input type='hidden' name='td-id' class='id' value='id'>"
. '" data-original-title="<b>Really delete</b>"><i class="fa fa-times"></i></button><a href="url" class="btn-option" data-toggle="mainmodal"><i class="fa fa-cog"></i></a>';

这将回显:

<button type="button" class="btn-option delete po" data-toggle="popover" data-placement="left" data-content="<a class='btn btn-danger po-delete ajax-silent' href='#'>Yes im sure</a><button class='btn po-close'>No</button> 
<input type='hidden' name='td-id' class='id' value='id'>" data-original-title="<b>Really delete</b>"><i class="fa fa-times"></i></button><a href="url" class="btn-option" data-toggle="mainmodal"><i class="fa fa-cog"></i></a>
<?php
$a = array(); 
$a["button"] = "<button type='button' class='btn-option delete po delete ajax' data-toggle='popover' data-placement='left' >Yes sure</button>";
echo $a["button"];
?>

code link

您也可以尝试其他方法如下:

<?php 
$a_tag = "<a class='btn btn-danger po-delete ajax-silent' href='#'>Yes im sure</a><button class='btn po-close'>No</button> <input type='hidden' name='td-id' class='id' value='id'>";
$a['button'] = '<button type="button" class="btn-option delete po" data-toggle="popover" data-placement="left" data-content="'.$a_tag.'" data-original-title="<b>Really delete</b>"><i class="fa fa-times"></i></button><a href="url" class="btn-option" data-toggle="mainmodal"><i class="fa fa-cog"></i></a>';
?>

我希望这会奏效