Catching object instantiation error

[email protected] ("Anh (Ly) Vuong")
Newsgroups php.version4
Organization Cisco Systems, Inc.
Message-ID <[email protected]>
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?

Thanks,
Ly Vuong
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.