[Solved] how to output google script with php


Use a heredoc:

$this->output(<<<EOF
<script>   (function() {
    var cx = '011900192141920744246:n9jj1rxodww';
    var gcse = document.createElement('script');
    gcse.type="text/javascript";
    gcse.async = true;
    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
        '//www.google.com/cse/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
</script>
<gcse:search></gcse:search>
EOF
);

If this doesn’t work, check your output function.

0

solved how to output google script with php