`

PHP Notice: Undefined index: ... 问题的解决方案

    博客分类:
  • PHP
PHP 
阅读更多
首先,这个不是错误,是warning。所以如果服务器不能改,每个变量使用前应当先定义。

方法1:服务器配置修改
修改php.ini配置文件,error_reporting = E_ALL & ~E_NOTICE

方法2:对变量进行初始化,规范书写(比较烦琐,因为有大量的变量)。但还没有找到好定义方法,望大家指教

方法3:每个文件头部加上:error_reporting(0); 如果不行,只有打开php.ini,找到display_errors,设置为display_errors = Off。以后任何错误都不会提示。ini_set("display_errors", 0);
方法4 :做判断:isset($_GET["page"])      if-else判断

或者加上'@'表示这行如果有错误或是警告不要輸出
如:@$page=$_GET["page"]

方法5:file1.php文件把$xx变量付一个值,用post传递给file2.php,
如果file2.php没有$xx的定义,而直接使用$yy=$xx; 系统就会报错:"undifined variaable $xx", 如果file2.php的文件开始用$xx="";定义,那么file1.php的$xx值就传不过来了!

file2.php里可以这样
if(!isset($xx)) $xx="";
分享到:
评论

相关推荐

    php Notice: Undefined index 错误提示解决方法

    字面意思就是未定义的索引,一般情况下是因为程序开发作者判断不严谨导致。一般不会影响程序的运行,具体的解决方法可以参考下。

    Notice: Undefined index: page in E:\PHP\test.php on line 14

    Notice: Undefined index: page in E:PHPtest.php on line 14

    PHP提示Notice: Undefined variable的解决办法

    需要设置显示错误级别,来解决问题。 网络上的通用解决办法是修改php.ini的配置: 解决方法: 1) error_reporting设置: 找到error_reporting = E_ALL 修改为error_reporting = E_ALL & ~E_NOTICE 2) register_...

    PHP运行出现Notice : Use of undefined constant 的完美解决方案分享

    Notice: Use of undefined constant ALL_PS – assumed ‘ALL_PS’ in E:\Server\vhosts\www.lvtao.net\global.php on line 50 Notice: Undefined index: EaseTemplateVer in E:\Server\vhosts\...

    php Undefined index和Undefined variable的解决方法

    $act $ POST["act"]; 用以上代码总是提示 Notice: Undefined index: act in F: windsflybook post php on line 18 另外 有时还会出现 引用内容 Notice: Undefined variable: Submit

    万年历的代码

    <!DOCTYPE ...<... <head> <... charset=utf-8" /> ... <div id='festival_detail_str'>1月22日至1月28日放假7天,1月21日(星期六)、1月29日(星期日)上班。...

    php Undefined index的问题

    又是一个提交程序的小bug,以前写程序的时候对提交数据几乎没做什么验证判断,比如接受 tj 的值,根本就没有定义数据类型就直接进行提交了,所以导至了 Notice: Undefined index: tj in //index.php on line 67 这样...

    PHP 中提示undefined index如何解决(多种方法)

    使用以上代码总是会提示Notice: Undefined index: act in D:\test\post.php on line 20另外,有时还会出现Notice: Undefined variable: Submit …… 等一些这样的提醒提示出现上面这些是 PHP 的提示而非报错,PHP ...

    php提示undefined index的几种解决方法

    用以上代码总是提示 Notice: Undefined index: act in D:\test\post.php on line 20 另外,有时还会出现 Notice: Undefined variable: Submit …… 等一些这样的提示 出现上面这些是 PHP 的提示而非报错,PHP 本身...

    Ashampoo(阿香婆)最新全系列注册机-2010-07-03发布

    注册机包含以下系列: ...(详细使用方法参见这里:http://bbs.bios.net.cn/viewthread.php?from=notice&tid=147622)..... 原版官方软件下载地址:http://www2.ashampoo.com/webcache/html/1/prod_overview_18_RMB.htm

    http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd

    granted in perpetuity, provided that the above copyright notice and this paragraph appear in all copies. The copyright holders make no representation about the suitability of the DTD for any ...

    php.ini-development

    Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ; Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT ; html_errors ; Default Value: On ; Development Value: ...

    PHP新手NOTICE错误常见解决方法

    页面中,好多类似 Notice: Use of undefined constant title – assumed ‘title’ in D:\wamp\www\phpmysqlweb\bbs\list.php on line 17 页面很难看,很纠结啊,我用的是wamp集成包。 百度了下,看来好多朋友也有...

    apache-maven-3.8.5

    比较大,里面包含了库文件... 1 atlas atlas 5141 3月 5 11:30 NOTICE -rwxrwxr-x. 1 atlas atlas 2612 3月 5 11:30 README.txt drwxrwxr-x. 59 atlas atlas 4096 6月 17 17:49 repository 注意setting配置文件仓库地址

    webstar php留言板 v4.6.rar

    webstar php留言板,运行... 1、主要解决了大家经常跟我提出的页面出现“Notice: Undefined variable...”的问题  2、更改了部分文件的位置和内容,以减少新手们的学习成本和代码的简洁性  3、修正了部分错误链接

    Xamarin.Android 4.8.00013 & Xamarin.iOS 1.3.250.0 Patched Executable V2

    Notice: v2: fix gc error. INSTRUCTIONS 1. Copy "mandroid.exe" to "C:\Program Files (x86)\MSBuild\Xamarin\Android" (or "C:\Program Files\MSBuild\Xamarin\Android" if you are on a 32-bit operating ...

Global site tag (gtag.js) - Google Analytics