faqts : Computers : Programming : Languages : PHP : kms : Classes

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 9 people (56%) answered Yes
Recently 1 of 1 people (100%) answered Yes

Entry

How can I tell if a class is defined?

Aug 4th, 1999 08:49
Nathan Wallace, Werner Stuerenburg


You can do it this way:

    if(!defined("__PREPEND_INCLUDE_INC__"))
        include("$DOCUMENT_ROOT/php3/phplib6/prepend.php3");

and in prepend.php3, I begin with

    if(!defined("__PREPEND_INCLUDE_INC__"))
        define("__PREPEND_INCLUDE_INC__",1);



Nice way, but you need to manage your includes with an if-statement. An 
alternative solution may be

prepend.php3:

   if(!defined("__PREPEND_INCLUDE_INC__")) {
      define("__PREPEND_INCLUDE_INC__",1);

      // your code

   }

So you can leave your include simple.