echo("<table>\n"); echo("<tr><td></td></tr>n"); echo("</table>);・・・等
/*sample.php*/ <html> <head> <?php $a = "apple"; $t = "test"; ?> <script> var a ="<?=$a?>"; </script> <script src="sample.js"> </head> <body> </body> </html> /*sample.js*/ alert(a); //javascriptとしてvar aに値を入れているので成功する alert("<?=$t?>"); //PHP上の変数は外部読み込みのjavascriptでは使えない。よって<?=$t?>と表示されたりする。