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

PHP 解决未定义变量报错

WBOY
WBOYOriginal
2016-06-06 19:49:211055browse

在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'];

  

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
Previous article:PHP cURL中CURLOPTNext article:PHP开发中utf8、utf