php Notice:Undefined index错误解决办法
Jun 02, 2016 am 09:14 AMUndefined index是告诉我们变量未定义或变量申明有点问题才会告诉我们一个并不致命的warning,那么我们要如何来解决这些问题呢?下面小编来给各位整理了一些解决warning问题的方法.
1.找到未定义变量进行处理,代码如下:
addslashes(htmlspecialchars(isset($_POST[$str])?$_POST[$str]:''));
2.把错误给过滤掉,代码如下:
@$page=$_GET["page"];
3.修改php.ini配置文件进行所有错误过滤,代码如下:
error_reporting = E_ALL & ~E_NOTICE 或者:
ini_set( "error_reporting", E_ALL ^ E_NOTICE );
ini_set( "display_errors", "0" );
4.在程序中直接加一个处理,代码如下:
if(!$cfg['debug']) { error_reporting(0); ob_start('ob_gzhandler'); }else { error_reporting(E_ALL ^ E_NOTICE); }
Copy after login
5.在php文件最开始处加如下一句代码:error_reporting(0);
总结:上面所有方法中最好的方法是方法一,这样在对程序性能上是有很好的帮助,如果你页面错误过多直接过滤掉会影响性能的,我以前介绍过一篇这样的文章大家可在本地搜索.
永久链接:
转载随意!带上文章地址吧。
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
