How to use a php inside js
<p>When i use the php and js separately it is working correctly </p>

<pre><code>&lt;script&gt; var test = 'asdasdasd'; &lt;/script&gt; &lt;?php $id =
"&lt;script&gt;document.write(test)&lt;/script&gt;"; echo $id; ?&gt;
</code></pre>

<p>But when I use the php inside the js function it is not working correctly </p>

<pre><code>&lt;script&gt;    var test = 'asdasdasd'; &lt;?php $id =
"&lt;script&gt;document.write(test)&lt;/script&gt;"; echo $id; ?&gt; &lt;/script&gt;
</code></pre>

<p>How can make work my second  code?</p>