Php 如何解决未定义索引错误

Php 如何解决未定义索引错误,php,undefined-index,Php,Undefined Index,注意我得到的错误: 未定义索引:中的标题 C:\xampp\htdocs\ICT\abc\cal1\EventCalender\classes\EventRecordForm.php 第13行 在添加变量之前,只需在$\u GET变量上选中isset(): if(isset($\u GET['title'))$output.=$\u GET['title'] 发生错误的原因是$\u GET['title']尚未填充。在附加变量之前,只需检查$\u GET变量上的isset(): if(isset

注意我得到的错误:

未定义索引:中的标题 C:\xampp\htdocs\ICT\abc\cal1\EventCalender\classes\EventRecordForm.php 第13行

在添加变量之前,只需在
$\u GET
变量上选中
isset()

if(isset($\u GET['title'))$output.=$\u GET['title']

发生错误的原因是$\u GET['title']尚未填充。

在附加变量之前,只需检查
$\u GET
变量上的
isset()

if(isset($\u GET['title'))$output.=$\u GET['title']


发生错误的原因是尚未填充$\u GET['title'.

您正在测试许多变量,但没有一个是从中读取的变量

应为,例如:

if(isset($_SESSION['evt_year']) 
   || isset($_SESSION['evt_title']) 
   || isset($_SESSION['evt_sdate']) 
   || isset($_SESSION['evt_place']) 
   || isset($_SESSION['evt_stime']) 
   || isset($_SESSION['evt_etime']) 
   || isset($_SESSION['evt_desc'])) {
    $output.=$_GET['title']; //the error is here
}
else {
    $output.="";
}

您正在测试很多变量,但没有一个是从中读取的变量

应为,例如:

if(isset($_SESSION['evt_year']) 
   || isset($_SESSION['evt_title']) 
   || isset($_SESSION['evt_sdate']) 
   || isset($_SESSION['evt_place']) 
   || isset($_SESSION['evt_stime']) 
   || isset($_SESSION['evt_etime']) 
   || isset($_SESSION['evt_desc'])) {
    $output.=$_GET['title']; //the error is here
}
else {
    $output.="";
}

在检查/使用变量之前,需要定义或检查它是否确实存在。这已经在PHP5.3.0中引入

错误:

if (isset($_GET['title'])) {
     $output.=$_GET['title']; // there is no error here
}
$output = $_GET['title'];
正确:

if (isset($_GET['title'])) {
     $output.=$_GET['title']; // there is no error here
}
$output = $_GET['title'];

在检查/使用变量之前,需要定义或检查它是否确实存在。这已经在PHP5.3.0中引入

错误:

if (isset($_GET['title'])) {
     $output.=$_GET['title']; // there is no error here
}
$output = $_GET['title'];
正确:

if (isset($_GET['title'])) {
     $output.=$_GET['title']; // there is no error here
}
$output = $_GET['title'];

尚未设置$\u GET['title']。表单上是否定义了名为“title”的
,或者变量集是否在查询字符串中?变量集是否在查询字符串中。但仍然得到相同的未定义错误。。。我应该换别的东西吗?就像请求或发布一样。@Alin仅供参考,这是一个通知。通过将此
错误报告(E_ALL^E_NOTICE)
代码放在php文件的顶部,可以避免在页面中打印。这将打印出除通知之外的所有其他错误。话虽如此,;此类错误的最佳做法是定义变量。$\u GET['title']尚未设置。表单上是否定义了名为“title”的
,或者变量集是否在查询字符串中?变量集是否在查询字符串中。但仍然得到相同的未定义错误。。。我应该换别的东西吗?就像请求或发布一样。@Alin仅供参考,这是一个通知。通过将此
错误报告(E_ALL^E_NOTICE)
代码放在php文件的顶部,可以避免在页面中打印。这将打印出除通知之外的所有其他错误。话虽如此,;这种错误的最佳实践是定义变量。非常感谢。。我的救世主!非常感谢你。。我的救世主!非常感谢你。。我的救世主!非常感谢你。。我的救世主!