0
我試圖保護對我的div class =「posts」的訪問。使用未定義的常量getUser - 假定'getUser'錯誤
我只想看看用戶是否有權限,如果函數getUser存在。有
但I'm這錯誤,我不明白問題出在哪裏:
Notice: Use of undefined constant getUser - assumed 'getUser' in if(function_exists(getUser))
我的代碼:
if(function_exists(getUser))
{
if(!getUser($_SESSION['user']['id'], '1'))
{
echo 'Sorry, but you don't have permission to enter here';
}
else
{
?>
<!-- I show this div id he user have permission -->
<div class="pages" style="display:block">
....
<?php
}
}
//if the function does not exist
else
{
header('Location: ../index2.php');
}
?>
</div>
我的getUser功能,是一款功能看到用戶的水平:
function getUser($userId, $nivel=NULL){}
該函數有點誇張,但如果用戶級別有效,它將返回true,如果不可能,則返回false,以便使用userId讀取用戶。
謝謝,我是看到其他網站,而不是PHP手冊,他們使用沒有引號。但現在它起作用了!謝謝:) – John23
如果他們抑制錯誤,他們永遠不會看到你得到的警告 –