RE: Find a what class a variable is

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: John Comerford [mailto:johnc@xxxxxxxxxxxxxxxxxxxx]
> Sent: 27 April 2007 08:41
> To: php-general@xxxxxxxxxxxxx
> Subject:  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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux