Title: Automatic loading class library Author: Stangly Wrong in PHP5
In PHP4 I can load a library file, such as Test.inc.php file, we need to use include or Require (include_once or require_once) before the PHP file, and we can use one in PHP5 Automatic mechanism, load a library file, even if the __autoload () function is used;
// Test.inc.php class test {var $ name; function getName () {Return $ this-> name;} function setName ($ n) {$ this-> name = $ n;}}?>
// Test.php // AutoLoad Class File Function __autoload ($ class_name) {include ($ class_name. '. Inc.php');} // instantiate a class $ t = new test; // call class action $ T- > setname ('Stangly Wrong'); Echo $ T-> getName ();?>