NYCPHP Meetup

NYPHP.org

[nycphp-talk] Determing custom object types ...

Andrew Yochum andrew at digitalpulp.com
Tue Oct 28 14:10:33 EST 2003


On Tue, Oct 28, 2003 at 01:44:12PM -0500, jon baer wrote:
> $myObj = new MyObject();
> if (is_object($myObj, gettype($myObj))) {
>  ...
> }
> 
> this wont get an exact type (should return "object") ... but basically i
> want to know if you can do something like this ficticious method to
> determine object equality.  (coming from java where everything is an object
> to begin with).

Try:
    $myObj = new MyObject();
    if (is_a($myObj,'myobject')) {
        ...
    }

There are also the other class/object functions that may help such as
get_class, method_exists and is_subclass_of. See:

    http://www.php.net/manual/en/ref.classobj.php

HTH,

Andrew

-- 
Andrew Yochum
Digital Pulp, Inc.
212.679.0676x255
andrew at digitalpulp.com



More information about the talk mailing list