0

I have a simple PHP structure.

In admin_keys.php i have:

<?php
class admin_keys
{
    public $key;
    private $arr_keys = array("1", "2", "3");
    public function check_key_admin()
    {
        if(in_array($this->key,$this->$arr_keys))
        {
            return true;
        }else
        {
            return false;
        }
    }
}
?>

In ok.php i have:

<?php
include_once '../../all_keys.php';
$admin_keys = new admin_keys();
$admin_keys->key = "vailozluon";
$_isAdmin = $admin_keys->check_key();
  if( _isAdmin== false)
  {
    echo 'deo phai';
  }else { echo 'ok';}
?>

Im new so just bear with me I don't know why this is return Uncaught Error: Call to undefined method admin_keys::check_key any help will be appreciated.

thanks!

1
  • check_key_admin != check_key. Commented Jun 14, 2021 at 5:26

1 Answer 1

1

you are refering to function (i.e. check_key()) that does not exists in your class admin_keys. You have function named check_admin_key() but you are trying to access it as check_key() which does not exist apparently throwing an error. So just change the name of the function being called as

$_isAdmin = $admin_keys->check_admin_key();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.