Home  >  Article  >  Backend Development  >  PHP语言,未赋值的变量?该怎么处理

PHP语言,未赋值的变量?该怎么处理

WBOY
WBOYOriginal
2016-06-13 12:34:051248browse

PHP语言,未赋值的变量?
http://docs.php.net/manual/zh/language.types.null.php

问题:
1.

<br />
<?php<br />
    if ($x)        <br />
       echo "1";<br />
    else<br />
       echo "0";<br />
?><br />


ubuntu@ubuntu:~$ php /var/www/b.php
PHP Notice:  Undefined variable: x in /var/www/b.php on line 3

上面代码,第3行错了!

PHP语法,变量可以不赋值。
如果,变量不赋值,其值是:NULL。对么?
为什么编译,第3行出错呢?



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn