Using PHP to generate JavaScript works as expected, and using JavaScript to generate PHP works as expected, however using PHP to generate JavaScript to generate PHP does not seem to work.
Is there a problem with my code which is causing this to fail, or is it some sort of limitation?
<!-- Use JavaScript to generate PHP -->
<script type='text/javascript'>
function addComment()
{
alert("About to add some content");
document.write("<?php testFunction(); ?>");
}
</script>
<!-- Use PHP to generate JavaScript to generate PHP -->
echo "<script type='text/javascript'>";
echo "function addComment2()";
echo "{";
echo 'alert("About to add some content");';
echo 'document.write("<?php testFunction(); ?>");';
echo "}";
echo "</script>";
(testFunction() simply contains echo "Test";
)