我正在使用简单的机器论坛软件,我需要将此代码添加到index.template.php文件中。
echo '
<ins class='dp a3229' data-options='{"width":"728","height":"90","color_title":"eeeeee","color_desc":"4e88ce","color_border":"cccccc","effect":"random","fallback":"pub-3009185058478899^8943350103","notice":"7"}'></ins>
<script async type="text/javascript" src="//x.dpstatic.com/ad.js"></script>';
像上面这样做只是给我一个模板解析错误?
答案 0 :(得分:0)
您在单引号内使用单引号,这会产生解析错误。尝试逃避('
- &gt; \'
)您要echo
的代码中的单引号。
答案 1 :(得分:0)
使用此
echo '
<ins class=\'dp a3229\' data-options=\'{"width":"728","height":"90","color_title":"eeeeee","color_desc":"4e88ce","color_border":"cccccc","effect":"random","fallback":"pub-3009185058478899^8943350103","notice":"7"}\'></ins>
<script async type="text/javascript" src="//x.dpstatic.com/ad.js"></script>';
这里我通过在它之前添加反斜杠'\'来逃避所有单引号