[UPHPU] require_once vs. class_exists

Rusty Keele rusty.keele at yahoo.com
Fri Apr 18 10:13:49 MDT 2008


Hi,

  Which is a better approach to use:
  
  1. require_once('path/to/class.php');

  or

  2. if(!class_exists('path/to/class.php')) require('path/to/class.php');

  I have been using the first approach in all my files where I need to instantiate a specific class, but I am wondering if the second approach is more efficient?  Are there any benefits to using the second approach - such as less caching of objects - or do these two statements do the same thing?

Thanks,
Rusty


       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.


More information about the UPHPU mailing list