本例是PHP和javascript交互的例子
比如php中的$flags在本例中為true
盡管在php的flags=="false";$title是一個字符串
<?php
$string = "天上and地下";
$flags = "";
if(strpbrk($string
$title = explode("and"
$title_
$title_
$flags = "true";
}
else{
$title = $string;
$flags = "false";
}
?>
—>html
<html>
<head>
<meta http
<title></title>
<script type="text/javascript">
var display = function(){
var flags = "<?php echo $flags; ?>";
var $title_
var $title_
if(flags=="true"){
$title_
$title_
return;
}
if(flags=="false"){
$title_
//雖然這是一個假分支
//這個假分支也是必須編譯的
}
}
</script>
</head>
<body onload="display()">
<div id="title_
<div id="title_
</body>
</html>
From:http://tw.wingwit.com/Article/program/PHP/201311/21030.html