[英]Notice: Undefined index: in C:\wamp\www\tests\Joomla\Website\index.php on line 37
Hey i get this : Notice: Undefined index: in C:\\wamp\\www\\tests\\Joomla\\Website\\index.php on line 37 嘿,我得到了:注意:未定义索引:在C:\\ wamp \\ www \\ tests \\ Joomla \\ Website \\ index.php中的第37行
And my code is this : 我的代码是这样的:
<?php
$remarks=$_GET['remarks'];
if ($remarks==null and $remarks=="")
{
echo '';
}
if ($remarks=='success')
{
echo 'Registration Success';
}
?>
I don't understand why i get this . 我不明白为什么要得到这个。 Please help!
请帮忙!
First, you don't say where is the line 37... I ain't a wizard, but I can guess from the error... 首先,您不说第37行在哪里...我不是向导,但我可以从错误中猜测...
Since the error is Undefined index
, that must come from the line: 由于错误是
Undefined index
,所以必须来自以下行:
$remarks=$_GET['remarks'];
You should validate that $_GET['remarks']
is not null with isset($_GET['remarks'])
before trying to get it's value. 在尝试获取
$_GET['remarks']
的值之前,应使用isset($_GET['remarks'])
验证其是否为null。
Second, that line does not make any sence, since the $remarks
can never be null
and ""
: 其次,该行没有任何意义,因为
$remarks
绝不能为null
和""
:
if ($remarks==null and $remarks=="")
So I would write the code like this: 所以我会这样写代码:
<?php
$remarks = "";
if ( isset($_GET['remarks']) ) {
$remarks = $_GET['remarks'];
}
if ( $remarks == 'success' ) {
echo 'Registration Success';
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.