Mixing php and javascript -- under what conditions?
<p>Under what conditions can I put PHP into Javascript code?  Is it always ok? Is it just a bad idea? I am surprised I have not seen it more. </p>

<p>For example, I came across this..</p>

<pre><code>$('#thumbnail').imgAreaSelect({aspectRatio: '&lt;?php echo $thumb_height/$thumb_width;?&gt;', onSelectChange:preview}); 
</code></pre>

<p>..which was in an onpage script element.  I'm not so experienced, but I was just surprised that I had never seen mixed js/php before.  But can you put PHP in .js files as well?  If I set the file extension to .php, will the file be parsed?</p>
