Namespace Autoload works under windows, but not on Linux

Posted by EvilChookie on Stack Overflow See other posts from Stack Overflow or by EvilChookie
Published on 2010-05-19T00:40:06Z Indexed on 2010/05/20 19:00 UTC
Read the original article Hit count: 349

Filed under:
|
|

I have the following php code:

index.php

<?php
spl_autoload_extensions(".php");
spl_autoload_register();

use modules\standard as std;

$handler = new std\handler();
$handler->delegate();
?>

modules\standard\handler.php

<?php
namespace modules\standard {
    class handler {
        function delegate(){
            echo 'Hello from delegation!';
        }
    }
}
?>

Under Windows 7, running WAMP, the code produces the message "Hello from Delegation!" however under Linux, I get the following:

Fatal error: spl_autoload(): Class modules\standard\handler could not be loaded in /var/www/index.php on line 15

Windows is running PHP 5.3.0 under WAMP, and Linux is running the 5.3.2 dotdeb package under Ubuntu 9.10.

Is this a configuration issue on my linux box, or just a difference in the way namespaces and autoloading is handled on the different operating systems

© Stack Overflow or respective owner

Related posts about php

Related posts about namespaces