Creating an __autoload() Function : __autoload « Class « PHP






Creating an __autoload() Function

 
<?php
function __autoload($classname) {
    require_once "class-{$classname}.php";
}

$mydisk = new cd();
?>
  
  








Related examples in the same category

1.Automatically Loading Include Files with ___autoload()
2.__autoload( ) is called whenever you try to create an object of a class that hasn't been defined
3.__autoload() function automatically includes a class file.
4.Using the __autoload() Function