RE: [PHP] Find a what class a variable is

From: Date: Fri, 27 Apr 2007 08:16:29 +0000
Subject: RE: [PHP] Find a what class a variable is
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-253955@lists.php.net to get a copy of this message
> -----Original Message----- > From: John Comerford [mailto:johnc@optionsystems.com.au] > Sent: 27 April 2007 08:41 > To: php-general@lists.php.net > Subject: [PHP] Find a what class a variable is > > > Hi Folks, > > Is is possible to detect what class a variable is eg. > > $JC1 = new Button(); > $JC2 = new TickBox(); > > > Is it possible to find out what class $JC1 is ? > > TIA, > JC If you want check it is of a certain type, use the instanceof operator, e.g. if ($JC2 instanceof TickBox) echo '$JC2 is a TickBox'; else echo '$JC2 is not a TickBox'; E

« previous php.general (#253955) next »