0

重複の可能性:
書き込みコンテキストで関数の戻り値を使用できない

これが変数のソースです。

<?php
if ($admin->get_permissions()=3)
echo 'Welcome to the Admin Panel';
else
echo 'Sorry, You do not have access to this page';
?>

そして、if ステートメントで実際に呼び出そうとしているコードは次のとおりです。

public function get_permissions() {
        $username = $_SESSION['admin_login'];
        global $db;
        $info = $db->get_row("SELECT `permissions` FROM `user` WHERE `username` = '" . $db->escape($username) . "'");
        if(is_object($info))
            return $info->permissions;
        else
            return '';
    }

これは、else if ステートメントを使用して、ユーザーが承認されているページを呼び出す簡単な方法です。か、そう思った

4

2 に答える 2

2

You need to change

$admin->get_permissions()=3

to

$admin->get_permissions()==3

= is the assignment operator, and == is the equality comparison operator. The parser is telling you that you can't assign 3 to the result of a function. It doesn't make any sense to do that.

于 2012-10-07T03:36:17.503 に答える
0

= != ==

if ($admin->get_permissions() == 3)
于 2012-10-07T03:36:06.537 に答える