I have a PHP project structured as:
--root
|--dr1
| |---dr2
| |--testclass.php
|--start.php
|--bootstrap.php
The testclass.php contains:
namespace dr1\dr2;
class testclass {
...
}
The bootstrap.php contains:
define('DIR_SEP', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__) . DIR_SEP);
function __autoload($class)
{
$path = ROOT . str_replace('\\', DIR_SEP, $class);
$file = $path . '.php';
if( is_file($file) ) require_once($file);
}
spl_autoload_extensions('.php');
spl_autoload_register('__autoload');
and The start.php contains:
$class = 'dr1\dr2\testclass.php';
$obj = new $class();
When I run the start.php, I got the message dr1\dr2\testclass.php
is not found on start.php
on line 5. I could not figure out why. would anybody help. thanks a lot.