最近在学PHP,有点疑问,先看看下面的代码
<html>
<body>
<form action="test02.php" method="post">
username :<input type="text" name="username"/>
<input type="submit" value="submit" name="submit"/>
</form>
</body>
</html>点击提交后,跳到下面的页面代码处理
<?php
if(isset($_POST["submit"])) {
$usernme = $_POST["username"] ;
}
if(strlen($usernme) <6 ) {
echo "用户名不能小于6位" ;
}
?>我想问的是上面的$username变量的作用域不是只能在第一个if里面么??为什么第二个if也可以用到$username变量呢?求解答!!谢了
<html>
<body>
<form action="test02.php" method="post">
username :<input type="text" name="username"/>
<input type="submit" value="submit" name="submit"/>
</form>
</body>
</html>点击提交后,跳到下面的页面代码处理
<?php
if(isset($_POST["submit"])) {
$usernme = $_POST["username"] ;
}
if(strlen($usernme) <6 ) {
echo "用户名不能小于6位" ;
}
?>我想问的是上面的$username变量的作用域不是只能在第一个if里面么??为什么第二个if也可以用到$username变量呢?求解答!!谢了
这是因为你的php.ini中的register_globles = On.导致的.详情请搜索register_globles