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

WBOY
Release: 2016-06-13 12:34:05
Original
1247 people have browsed it

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 />
Copy after login


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

上面代码,第3行错了!

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



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!