Reputation: 1
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!
Upvotes: 0
Views: 528
Reputation: 539
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();
Upvotes: 1