Is it possible to autoload a file based on the namespace in PHP?

Posted by izym on Stack Overflow See other posts from Stack Overflow or by izym
Published on 2010-03-26T11:20:02Z Indexed on 2010/03/26 11:23 UTC
Read the original article Hit count: 223

Filed under:
|
|
|
|

Would what mentioned in the title be possible? Python module style that is. See this example for what I exactly mean.

index.php

<?php
use Hello\World;
World::greet();

Hello/World.php

<?php
namespace Hello\World;
function greet() { echo 'Hello, World!'; }

Would this be possible?

© Stack Overflow or respective owner

Related posts about php

Related posts about python