? ? ? ? ?ㄥ???擱」?????歸??褰?涓?锛?缁?甯鎬?????s涓?php???芥?頒?璋?????????瀹???涓?JS涓?php??璁捐?¤????涓????¤?涓ょ?璇?瑷??存?ヨ?琛?璋??ㄧ??锛?涓?涓???瀹㈡?風??璇?瑷?锛?涓?涓????$??璇?瑷?锛?涓よ??涔??寸??浜や?寰?寰???????ajax?哄?訛?get()锛?post()杩?琛??版????浼???????涓??ㄤ袱???ㄨ?琛??存?ヨ????寰?寰???浠ヤ??????訛?
1??棣???锛?php涓?JS涔??寸??浜?璋????藉?ㄥ??涓???浠堕??锛?瀵瑰?跺????浠剁??璋??ㄩ?戒?澶辮觸锛???璁烘??php杩???JS????
2??php涓?JS涔??寸??璋??ㄥ???介??瀵圭?????芥?幫???瀵瑰?????戒??藉???闆?????沖??<?php ? ??>"涓?php涓??藉???S??????锛? ?稿????<script> ?</script>"涓?JS涔?涓??藉???hp????????????杩?缃?涓???绱㈣?村??浠ュ???頒?璋?锛??????芥??娴?瑙??ㄥ?煎?圭????棰?锛???浜虹?ㄧ??娴?瑙??ㄦ??Google Chrome(???? 37.0.2062.103 m)锛?杩?涔??ㄤ?渚ч?㈣?存??php涓?JS???存?ヤ?璋?寰?瀹規???虹??UG??
3???ㄥ?芥?扮??璋??ㄦ?堕?借???杩????鹼?php??杩???echo??????return??灏??闆?艱???锛???JS??杩???document.write()??????return??灏??闆?艱?????
4??瀵瑰?芥?扮??璋??ㄦ?訛??借??ㄤ?涓?????灏??芥?頒??????ョ???艱?琛?淇?瀛???渚?锛???S涓??var y = "<?php JSphpTest()?>"; ??hp涓??? $phpB = "<script> phpJSTest()</script>";娉ㄦ??锛?璁闆??ㄥ?瑰?芥?拌??ㄦ?惰???涓?" "??寮??楓??
??涓??ㄥ??浠g??锛?
? ? ?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title><script language="JavaScript" src="javascript.js"></script>
<script language="JavaScript">
function JSTest()
{
var $tmp = "Hello, JS use the same file JS function";
return $tmp;
}
function phpJSTest()
{
document.write("Hello, php use the same file JS function");
}
var tmp = "php call the same file JS element";
document.write("<br/><br/><br/><br/>");
document.write("script---call---show :");
document.write("<br/>");
//use the same file js function
var x = JSTest();
document.write(x);
document.write("<br/>");
//use same file php function
var y = "<?php JSphpTest()?>";
document.write(y);
document.write("<br/>");
//use another file's JS function
var z = fileouter();
document.write(z);
document.write("<br/>");
</script>
<?php
function phpTest()
{
echo "Hello, php use the same php function";
}
function JSphpTest()
{
echo "Hello, JS use the same file php function";
}
include 'PHPcallOutfilePHP.php';
echo "<br/><br/><br/><br/>";
echo "php---call---show"."<br/>";
//php call the same file php function
$phpA = phpTest();
echo "$phpA"."<br/>";
//php use the same file JS function
$phpB = "<script> phpJSTest()</script>";
echo "$phpB"."<br/>";
//php use external file php function
$phpC = phpcalloutfilephp();
echo "$phpC"."<br/>";
?>
</head>
</html>
瀹??翠唬??涓?杞藉?闆??锛? http://download.csdn.net/detail/aba13579/7874961
??