Unexpected token Illegal
<p>I know there are other similar question related on stack overflow, but none seemed to correct my problem. This error occur on every browser (although I used webkit error name).</p>

<p>I need to add javascript using PHP. This cause the error "Unexpected token illegal" to appear. I tried this <a href="http://stackoverflow.com/a/4635492/1202691">answer</a> without success. This is what I have now :</p>

<pre><code>    $texte .="&lt;script&gt;";
    $texte .="$(function(){";
    $texte .="$('#field_".$this-&gt;id."').css('position','absolute').css('left','".$this-&gt;x."px').css('top','".$this-&gt;y."px');";
    $texte .="$('#field_".$this-&gt;id."').draggable({stop:function(event,ui){saveFieldPosition(".$this-&gt;id.");},grid:[10,10],containment:\".work_plane:first\"}).resizable({grid:[10,10]});";
    $texte .="});";
    $texte .="&lt;/script&gt;";

    return $texte;
</code></pre>

<p>I have enabled Dreamweaver hidden characters and remove every one that would be in $texte value.</p>

<p>Anyone sees the problem? Any hint would be appreciated.</p>

<p>Edit: the $texte is passed trough htmlentities() before it's added.</p>

<p>Here's the output :   </p>

<pre><code>    &amp;lt;script&amp;gt;$(function(){$('#field_1').css('position','absolute').css('left','px').css('top','px');$('#field_').draggable({stop:function(event,ui){saveFieldPosition();},grid:[10,10],containment:&amp;quot;.work_plane:first&amp;quot;}).resizable({grid:[10,10]});});&amp;lt;/script&amp;gt;
</code></pre>
