![](/img/trans.png)
[英]Notice: Undefined index: name in C:\wamp\www\chatsystem\index.php on line 63
[英]Notice: Undefined index: in C:\wamp\www\tests\Joomla\Website\index.php on line 37
嘿,我得到了:注意:未定義索引:在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';
}
?>
我不明白為什么要得到這個。 請幫忙!
首先,您不說第37行在哪里...我不是向導,但我可以從錯誤中猜測...
由於錯誤是Undefined index
,所以必須來自以下行:
$remarks=$_GET['remarks'];
在嘗試獲取$_GET['remarks']
的值之前,應使用isset($_GET['remarks'])
驗證其是否為null。
其次,該行沒有任何意義,因為$remarks
絕不能為null
和""
:
if ($remarks==null and $remarks=="")
所以我會這樣寫代碼:
<?php
$remarks = "";
if ( isset($_GET['remarks']) ) {
$remarks = $_GET['remarks'];
}
if ( $remarks == 'success' ) {
echo 'Registration Success';
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.