<?php
if (!empty (get_gpc('userId')))
{
$userId = get_gpc('userId');
}
else
{
$error = "ID doesn't exist";
}
報錯:
Fatal error: Can't use method return value in write context in (line number)
為什么?
empty()函數是檢查一個變量是否為空,但是 get_gpc() 是個函數,所以得改下,參考代碼如下:
<?php
$test = get_gpc('userId');
if (!empty($test))
{
$userId = get_gpc('userId');
}
else
{
$error = "ID doesn't exist";
}
