Home > Backend Development > PHP Tutorial > 第一天弄PHP,崩溃了,这都报错?

第一天弄PHP,崩溃了,这都报错?

WBOY
Release: 2016-06-13 11:55:46
Original
1291 people have browsed it

第一天搞PHP,崩溃了,这都报错???

<br />if($_GET['all']=='yes')<br />{<br />    echo "hi";  <br />}<br />
Copy after login

报错:Notice: Undefined index: all in C:\Users\Administrator\Downloads\PHPnow-1.5.6.4237493736\htdocs\oa\manage.php on line 71

小弟实在搞不清,一个等号 两个等号 到底有什么区别。
另外,如果改成一个等号,不报错了,但是这条语句也没有用了,url上面有all=yes 会出现hi, url上面没有all=yes还是会出现hi.

------解决方案--------------------
if(isset($_GET['all']) && $_GET['all']=='yes')
{
echo "hi";
}
------解决方案--------------------
$_GET['all'] 未定义,不是错误,只是提示。

可以用isset() 方法判断是否已定义再取值。

例如:
<br />if(isset($_GET['all']) && $_GET['all']=='yes')<br />{<br />    echo "hi";  <br />}<br />
Copy after login

------解决方案--------------------
一个等号 是赋值
 两个等号 才是等于

正确的写法应该先用isset判断一下。

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