开发者

PHP 5.3 Namespaces and use

i am wondering why my namespaces are not resolved correctly ... i have

use \Doctrine\ORM;
... 
} catch (NoResultException $e) { // shld resolve to \Doctrine\ORM\NoResultException but fails
... 
} catch () {
    // code always ends up here if NoResultExc开发者_Python百科eption is thrown
    // unless i fully qualify the class as\Doctrine\ORM\NoResultException
}


use \Doctrine\ORM;

This declare an alias named ORM that points to \Doctrine\ORM. It doesn't mean that all the class name you mention in your code will use this alias. You still have to specify that you want to use it like this :

catch (ORM\NoResultException) {

ORM\NoResultException will point to \Doctrine\ORM\NoResultException

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜