如何在用PHP编写的onclick中添加引号?

时间:2018-11-30 18:40:15

标签: php

我不知道标题是否有疑问,但是我将显示生成按钮的代码,并且我需要将变量用引号引起来,如下所示:onclick =“ anything(value)”-> NOW

onclick =“任何东西(“值”)”->我想如何

$btn = '<button type="button" onclick="button('.$id.')" class="btn blue-madison btn-sm" style="margin:0px;">Gerenciar</button>';

1 个答案:

答案 0 :(得分:0)

下面是一个双引号引起来的字符串,它允许您在其中放置单引号,并通过像\“一样转义来使用双引号。此外,变量在双引号引起来的字符串中被其值替换。

$btn = "<button type=\"button\" onclick=\"button('$id')\" class=\"btn blue-madison btn-sm\" style=\"margin:0px;\">Gerenciar</button>";