You betcha. probably the easiest example would be from a JS folding tree that we use. It uses a flat file to build the tree structure. However, we wanted to have users be able to use a blind login for another web application, so that they wouldnt have to type in the identical info. So I have a PHP page that generates the Javascript that controls the folding tree, and WITHIN that javascript page, I have also generated php. Confusing, I know. But thats one of the ways that I have used it. And let me tell you, figuring out just what to escape is a big ol pain in the hiney. the following example is from the PHP which generates the JS:
$line.="<?\n";
$line.="\$execs=file(\"/whatever\");\n";
$line.= "if (strstr(\$execs[0],\$PHP_AUTH_USER)){\n";
$line.= "print \"";
$line.="insDoc(fT, gLnk(\\"Executive Reports\\",\\"exec_apps/index.html\\"))\n\";\n";
$line.="}\n";
$line.="if((\$PHP_AUTH_USER == \"user1\")||(\$PHP_AUTH_USER == \"user2\")||(\$PHP_AUTH_USER == \"user4\")||(\$PHP_AUTH_USER == \"user3\")||(\$PHP_AUTH_USER == \"user5\")){\n";
$line.= " print \"";
$line.= "insDoc(fT, gLnk(\\"Folding Tree Admin\\", \\"/yaddal/driver.html\\")).setTarget(1)\n\";\n";
$line.="}\n";
$line.="?>\n";
$line.="\n";
$res=fwrite($fp,$line);
Pardon the wrapping, but Im sure you get the idea. Hope this helps!
Darren