How to execute Javascript code from a PHP function?
<p>Ok, what I'm doing right now is just echoing an script tag. For example:</p>

<pre><code>echo '&lt;script&gt;alert("Hello world")&lt;/script&gt;';
</code></pre>

<p>Is this the right way to do this? or is there a better way?</p>
