注意:未定义的索引:在C:\wamp\www\tests\Joomla\Website\index.php的第37行
注意:未定义的索引:在C:\wamp\www\tests\Joomla\Website\index.php的第37行 我的代码是:注意:未定义的索引:在C:\wamp\www\tests\Joomla\Website\index.php的第37行,php,notice,Php,Notice,注意:未定义的索引:在C:\wamp\www\tests\Joomla\Website\index.php的第37行 我的代码是: <?php $remarks=$_GET['remarks']; if ($remarks==null and $remarks=="") { echo ''; } if ($remarks=='success') { echo 'Registration Success';
<?php
$remarks=$_GET['remarks'];
if ($remarks==null and $remarks=="")
{
echo '';
}
if ($remarks=='success')
{
echo 'Registration Success';
}
?>
我不明白为什么我会得到这个。请帮忙 首先,你不要说37号线在哪里。。。我不是巫师,但我能从错误中猜出来 由于错误是
未定义索引
,因此必须来自以下行:
$remarks=$_GET['remarks'];
在尝试获取其值之前,应使用isset($\u GET['marks'])
验证$\u GET['marks']
是否不为空
第二,这一行没有任何意义,因为
$markes
永远不能null
和”
:
所以我会这样写代码:
<?php
$remarks = "";
if ( isset($_GET['remarks']) ) {
$remarks = $_GET['remarks'];
}
if ( $remarks == 'success' ) {
echo 'Registration Success';
}
?>
这将有助于您确定代码中的哪一行是
第37行
。帖子中也不需要您的HTML,因为这是一个PHP错误。此外,if($comments==null和$comments==“”)行可能应该有一个或而不是and(因为$comments不能同时为null和“”):if($comments==null或$comments==“”)
<?php
$remarks = "";
if ( isset($_GET['remarks']) ) {
$remarks = $_GET['remarks'];
}
if ( $remarks == 'success' ) {
echo 'Registration Success';
}
?>