Home > php教程 > php手册 > body text

PHP 解决未定义变量报错

WBOY
Release: 2016-06-06 19:49:21
Original
1087 people have browsed it

在PHP中 有时候会出现 Notice : Undefined index: sid in D:\Apache Group\Apache2\htdocs\php_mobile\mobile\chao\sinnsei_publish.php on line 10 这个报错,原因是因为没有定义,因为PHP是弱类型语言,和JAVA等不一样,不一定要初始化,所以这种问题其实

在PHP中 有时候会出现

Notice: Undefined index: sid in D:\Apache Group\Apache2\htdocs\php_mobile\mobile\chao\sinnsei_publish.php on line 10

 

这个报错,原因是因为没有定义,因为PHP是弱类型语言,和JAVA等不一样,不一定要初始化,所以这种问题其实不是什么大问题

不过,出现在页面上确实不好看,

方法一:初始化变量进行赋值

方法二:加@来对错误进行抑制

$sid = @$_POST['sid'];
Copy after login

  

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template