0

I have a function on load that checks a users login status. Here is a small chunk of the code...

//
// user is logged in, get user info
$user = Model\User::getByKey($_COOKIE['ukey']);
if($user->field('id') >= 1 || !isset($status)) {
    //
    // establish google connection
    Classes\Google\Google::construct($user->field('id'), $user->field('ga_account'));

...

I have an __autoload function which finds the path of the file perfectly fine. However, I get a fatal error because the "\Classes\Google\Google" class is not found.

new Google() ... is located at /classes/google/google.class.php. The file is there, the autload function has the correct file path but why isn't the class found?

I do not have any namespacing on this particular Google() class file. This is all custom built, not a third party framework.

0

1 Answer 1

1

1- use class_exists to make sure class is loaded . 2- if class not loaded , in google.class.php make a die , so u'll know file loaded or not. 3- if class loaded , make a new object here . the test it , so u can find the class definition is true or not.

Sign up to request clarification or add additional context in comments.

1 Comment

I am using the php function called __autoload. php.net/manual/en/function.autoload.php So this function finds my google.class.php file, loads it with require_once but than rest of my script fails when trying to call Google().

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.