开发者

Including files in namespace

I have small problem with name spaces in php 5.3. I've made declaration for namespace:

use \com\me\libs as Libs;

And I can't find answer how to include file in that namespace using "Libs"... I can do

include('com/me/libs/functions.php');

but I'm trying to find more "clear" way to do 开发者_高级运维this... Like declaring object:

$foo = new Libs\Foo.php

And second question. I'm trying to make php file returning JSON array. To do this I have to include "Connection.php" class. But when I include this file (same folder) I got error with implementation file not found (same folder, same namespace)...


First question: You can use an autoloader. See spl_autoload_register() for further information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜