SOLVED! Detect class isset while !triggering nonobject error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

SOLVED! Detect class isset while !triggering nonobject error

Post by JAB Creations »

I'm trying to merely detect is a class isset and if it's not to include a file...

Code: Select all

if (
!isset(
$error->get('query')
)) {include("includes.php");}
However on every other page where the class !isset I get the following error message...
Call to a member function get() on a non-object
I thought that was the point of determining if it's set or not?! :roll:
Last edited by JAB Creations on Mon Mar 10, 2008 2:20 pm, edited 1 time in total.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Detect class isset while !triggering non-object error?

Post by alex.barylski »

get_declared_classes()
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Detect class isset while !triggering non-object error?

Post by JAB Creations »

Thanks! Thank goodness for see also on php.net! :mrgreen:

Code: Select all

if (!class_exists('error')) {include("includes.php");}
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Detect class isset while !triggering non-object error?

Post by alex.barylski »

Thats the one. :)
Post Reply