Re: [PHP4BETA] Catching object instantiation error

From: Date: Thu, 25 May 2000 20:12:37 +0000
Subject: Re: [PHP4BETA] Catching object instantiation error
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-15762@lists.php.net to get a copy of this message
Thanks Andrei. Oh man! I love this mailing list! :) Cheers, Ly ---- Andrei Zmievski wrote: > > On Thu, 25 May 2000, Anh (Ly) Vuong wrote: > > Hello, > > > > Hope someone out there can help me. > > > > I am trying to catch error or prevent from instantiate a non existing > > object class. I use: > > > > class A > > { > > ... > > } > > > > $className = "A"; > > $obj = new $className; > > ... > > $className = "B"; > > $obj = new $className; > > > > > > I would like to catch the error in the second part of the code, is there > > a function to check if the class definition exist before the > > instantiation? > > Yes, class_exists($classname) will give you what you want. > > -Andrei > * Change is the only constant. *

« previous php.version4 (#15762) next »