这篇文章给大家分享的是关于如何在php中输出js语句,有需要的朋友可以参考一下
怎样在php中输出js语句?
示例
php<?php
$classState="";
if($state==0){
$classState="已下课";
}
else{
$classState="正在上课";
}
echo "<script type='text/javascript'>
function getState(){
var cs = ".$state.";
return cs;
}
</script>";
?>这样在页面的其他地方,就可以直接引用php中输出的js方法了.











