Get the exact name/type of a user-defined object

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
mcccy005
Forum Contributor
Posts: 123
Joined: Sun May 28, 2006 7:08 pm

Get the exact name/type of a user-defined object

Post by mcccy005 »

I have written several form classes (eg. text_field, radio_field etc.) including a comment_field object.
I need to determine if a particular object is of type 'comment_field'.

gettype( ) appears to only return a list of known objects (boolean, integer, string etc) and 'resource' (which I think is supposed to represent any user-defined function and probably other things.
Is there a function I can call which will return the string name of the object??

Eg.

Code: Select all

$comment = new comment_field( );
if(<<get_object_type_function>>($comment)=='comment_field') break
else ....

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply