SPL_autoload example script


/ Published in: PHP
Save to your folder(s)

check out why the get_include_path() was appended to the new path.


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. set_include_path(realpath('/path/to/lib') . PATH_SEPARATOR . get_include_path());
  4.  
  5. function autoload($className)
  6. {
  7. require($className . '.php');
  8. }
  9.  
  10.  
  11. $Database = new Database();
  12.  
  13. ?>

URL: http://www.brandonsavage.net/making-life-better-with-the-spl-autoloader/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.