您需要转义引号,或使用double,或使用heredoc:
// Escaped
return \'<div id="xxxx-xxxxxx"></div>
<script type="text/javascript">
window._taboola = window._taboola || [];
_taboola.push({
mode: \\\'xxxxxxx-xxxxx\\\',
container: \\\'xxxxxx-xxxxxxx\\\',
placement: \\\'one word word\\\',
target_type: \\\'mix\\\'
});
</script>\';
// Doubles
return \'<div id="xxxx-xxxxxx"></div>
<script type="text/javascript">
window._taboola = window._taboola || [];
_taboola.push({
mode: "xxxxxxx-xxxxx",
container: "xxxxxx-xxxxxxx",
placement: "one word word",
target_type: "mix"
});
</script>\';
// Heredoc
return <<<html
<div id="xxxx-xxxxxx"></div>
<script type="text/javascript">
window._taboola = window._taboola || [];
_taboola.push({
mode: "xxxxxxx-xxxxx",
container: "xxxxxx-xxxxxxx",
placement: "one word word",
target_type: "mix"
});
</script>
html;