问题
i got problem with a login script, the thing is i've already instantiated the object, but still got the message saying "Call to a member function on a non-object". Also, note that this code works on localhost, but when i try to run it online i get this message.
have two php files:login.php and connect.php
here is simplified code from connect.php
class Connect{
var $logged;
function check_login($uname, $pass){
$db=new DB;
$hashed_password=$db->get_password();
if( $pass == $hashed_password){
$this->logged=true; // works - i checked with die() function
..
}
}
function simple(){
return 'yes';
}
}
$user=new Connect;
here is simplified code from login.php
include_once('connect.php');
$user->check_login($uname, $pass); // works
var_dump($user->logged); // i get NULL - why!?
$data=$user->simple(); // doesn't work!
Does anyone know why i get empty attributes and this message when i try to call simple() method?
来源:https://stackoverflow.com/questions/7625941/call-to-a-member-function-on-a-non-object-works-localhost-but-not-online