Home > php教程 > php手册 > PHP 解决未定义变量报错

PHP 解决未定义变量报错

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:49:21
Original
1151 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

  

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