PHP程序中的 Notice: Undefined index: 10个免费的高品质WordPress杂志主题下载
来源:互联网 发布:vr技术与人工智能 编辑:程序博客网 时间:2024/05/01 23:58
http://www.iteye.com/news/20245
10个免费的高品质WordPress杂志主题下载
1. 修改 php.ini 文件中
error_reporting = E_ALL
为
error_reporting = E_ALL & ~E_NOTICE
2.使用代码
ini_set( ‘error_reporting’, E_ALL ^ E_NOTICE );
ini_set( ‘display_errors’, ’0′ );
3.使用@抑制错误
@$name = $_GET['name'];
4.进行判断
关闭 PHP 提示的方法 搜索php.ini: error_reporting = E_ALL 改为: error_reporting = E_ALL & ~E_NOTICE 还有个不是办法的办法就是 在每个文件头上加 error_reporting(0); 虽然不好弄但是可以解决问题!!!!!!这个比较好用本来php是不需要定义变量的,但是出现这种情况应该怎么办呢?在php.ini中的302行 error_reporting = E_ALL修改成error_reporting = E_ALL & ~E_NOTICE 再重启apache就行了如果什么错误都不想让显示,直接修改:display_errors = Off如果你没有php.ini的修改权限,可在php头部加入ini_set("error_reporting","E_ALL & ~E_NOTICE");即可方法1:服务器配置修改 修改php.ini配置文件,error_reporting = E_ALL & ~E_NOTICE 网络上的通用解决办法是修改php.ini的配置: 解决方法: 1) error_reporting设置: 找到error_reporting = E_ALL 修改为error_reporting = E_ALL & ~E_NOTICE 2) register_globals设置: 找到register_globals = Off 修改为register_globals = On 我发现在php代码中直接使用 error_reporting(E_ALL & ~E_NOTICE); 可以解决这个问题,小技巧记一下,呵呵。我的程序首选是没有错误的,可以执行,当时程序总是提示 Notice: Undefined index: 这样的信息。程序代码如下:<?php include("conn.php"); if($_POST['submit']){$sql="insert into message (id,user,title,content,lastdate) " . "values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())"; mysql_query($sql); echo "<script language=\"javascript\">alert('添加成功');history.go(-1)</script>"; } include("head.php");?><SCRIPT language=javascript>function CheckPost(){ if (myform.user.value=="") { alert("请填写用户名"); myform.user.focus(); return false; } if (myform.title.value.length<5) { alert("标题不能少于5个字符"); myform.title.focus(); return false; } if (myform.content.value=="") { alert("必须要填写留言内容"); myform.content.focus(); return false; }}</SCRIPT> <form action="add.php" method="post" name="myform" onsubmit="return CheckPost();"> 用户:<input type="text" size="10" name="user" /><br> 标题:<input type="text" name="title" /><br/> 内容:<textarea name="content" cols="60" rows="9"></textarea><br/> <input type="submit" name="submit" value="发布留言"/></form>if( !empty($_GET['name']) ) $name = $_GET['name'];
首先,这个不是错误,是warning。所以如果服务器不能改,每个变量使用前应当先定义。方法1:服务器配置修改修改php.ini配置文件,error_reporting = E_ALL & ~E_NOTICE方法2:对变量进行初始化,规范书写(比较烦琐,因为有大量的变量)。但还没有找到好定义方法,望大家指教方法3:每个文件头部加上:error_reporting(0); 如果不行,只有打开php.ini,找到display_errors,设置为display_errors = Off。以后任何错误都不会提示。方法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=”";
0 0
- PHP程序中的 Notice: Undefined index: 10个免费的高品质WordPress杂志主题下载
- 运行PHP程序时提示“Notice: Undefined index”的解决办法
- PHP Notice: Undefined index:
- PHP Notice: Undefined index: ... 问题的解决方案
- PHP Notice: Undefined index: ... 问题的解决方案
- PHP Notice: Undefined index: ... 问题的解决方案
- PHP Notice: Undefined index: ... 问题的解决方法
- PHP Notice: Undefined index: ... 问题的解决方案
- PHP Notice: Undefined index: ... 问题的解决方法:
- PHP Notice: Undefined index: ... 问题的解决方法:
- PHP Notice: Undefined index: ... 问题的解决方法:
- PHP Notice: Undefined index: ... 问题的解决方法:
- PHP Notice: Undefined index: ... 问题的解决方案
- 10个高品质的免费图库站点下载高清图片
- php 解决Notice: Undefined index:
- PHP Notice: undefined index 解决方法
- PHP Notice: Undefined index和Undefined variable问题的解决方法:
- PHP中出现Notice: Undefined index的三种解决办法
- spring websocket Converters must not be empty
- cocos2d3.X真机调试-Android
- .net中如何读取服务器上指定文件夹中的所有文件 (百度知道 )
- snmp添加私有库——收藏
- centOS中找不到ifcongfig命令解决办法
- PHP程序中的 Notice: Undefined index: 10个免费的高品质WordPress杂志主题下载
- 使用poi做excel导出时解决以文本格式存储的数字问题
- Spring中Bean的生命周期
- 分形之分形龙
- eXtremeTable原理
- js数组的操作
- Android 学习日志
- Android学习笔记——保存数据到SQL数据库中(Saving Data in SQL Databases)
- spring事务配置几种方式