if (empty($app->GetCookie('username')))
{
echo 'Error';
}如果仅仅看这几句是没问题的

解决方案 »

  1.   

    --------------------------
    class app
    {
    function getuser()
    {
    return 123345;
    }
    }
    $tb = new app;
    if (empty($tb->getuser()))
    {
    echo 'NO';
    }
    ---------------------------
    这样就会报错
    但是
    if (!($tb->getuser()))
    就正常还有就是if (tostr($tb->getuser()))tostr()实自定义函数
    这样也是正常的
      

  2.   

    empty的参数必须是变量。
    $v=$app->GetCookie('username')
    if(empty($v))
    .....