Passing a PHP variable to JavaScript
<p>I am having problems passing any kind of variable from PHP to JavaScript. Here is a simple example at jsFiddle. Why does it not return my string?</p>

<p><a href="http://jsfiddle.net/funinabox/VkNe2/1/" rel="nofollow">http://jsfiddle.net/funinabox/VkNe2/1/</a></p>

<pre><code>&lt;?php
//create php test string    
$teststring = "mystring"; 
?&gt;


//Convert Php string to JavaScript string
var testvar = &lt;?php echo $teststring; ?&gt; ;
//Display output of the array elements;
alert(testvar);
</code></pre>
