Could someone please explain why the following code works:
<html>
<head>
<script type="text/javascript">
function test(){
phpTest = "<?php echo \'hello\'; ?>";
document.getElementById("php_code").innerHTML = phpTest;
}
</script>
</head>
<body>
<a href="#" onclick="test(); return false;"> test </a>
<span id="php_code"> </span>
</body>
<html>
while this code doesn't:
<html>
<head>
<script type="text/javascript">
function test(){
phpTest = "<?php echo \'hello world\'; ?>";
document.getElementById("php_code").innerHTML = phpTest;
}
</script>
</head>
<body>
<a href="#" onclick="test(); return false;"> test </a>
<span id="php_code"> </span>
</body>
<html>
(NB: the only difference is, that the first string says 'hello', and the second 'hello world')