In PHP how can i check if class exists?

In PHP how can i check if class exists?

Try using, class_exists() http://php.net/manual/en/function.class-exists.php

In your case, looking for dbinfo class do this:

      if(class_exists(dbinfo)){
          //do something

If your class has a namespace, include the ful namespaced classname.

class_exists(class_name,false);

Set false to true if the function should try too load the class.

In PHP how can i check if class exists?

Leave a Reply

Your email address will not be published.