方法一:
<?php header("Content-Type:text/html;charset=utf-8"); function show(){ $a= 12345; return $a; } ?> <script language="JavaScript"> function bt_click(){ alert("<?php echo show(); ?>"); } </script> <input type="button" name="show" id="show" value="提交" onClick="bt_click();"/>
方法二:
<?php header("Content-Type:text/html;charset=utf-8"); function show(){ $a=12345; echo $a; } ?> <script language="JavaScript"> function bt_click(){ alert("<?php show(); ?>"); } </script> <input type="button" name="show" id="show" value="提交" onClick="bt_click();"/>