php变量作用域if语句


php variable scope if statement

这是一个PHP中的服务器端脚本。我是PHP新手。即使if语句中的条件为true,我也无法找出为什么变量$n、$g和$d没有被修改。全局声明也无效。

<!DOCTYPE html>
<html>
<head><title>IFRAME</title></head>
<body>
<script type="text/javascript">
<?php
    extract($_GET);
    $n="";$d="";$g="";
    if(strcmp($usn,"1se501"))
    {
       global $n,$d,$g;
       $n="bob";
       $d='cse';
       $g='8.8';
    }
    echo "parent.updateRes('$n','$d','$g');";
?>
</script>
<h2>Server done...</h2>
</body>
</html>

页面正在被缓存。因此,我的代码中的更改没有得到反映。代码没有问题。