PHP variable in Javascript
<p>Consider this simple example;</p>

<pre><code>&lt;?php $text = test; ?&gt;

&lt;script type="text/javascript" defer="defer"&gt;

var test;

test = "&lt;?php echo $text; ?&gt;"

$(document).ready(function(){
alert(test);
});

&lt;/script&gt;
</code></pre>

<p>This works fine. Creating the alert with the text from the php var. However, if I place; </p>

<pre><code>&lt;?php $text = test; ?&gt;
</code></pre>

<p>below the script - it does not work. I've tried the defer function. What am I doing wrong? </p>

<p>Cheers</p>
