Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
php中的use语句是否考虑了当前的命名空间?
例如,如果
<?php namespace Star; use Sun;
这是否意味着,Sun是Star\Sun的别名?
这是否意味着,Sun 是 Star\Sun 的别名?
没有。示例:
<?php namespace Trash; use B; class A { function __construct() { $b = new B; } } namespace Trash; class B {} var_dump(new \Trash\A);
此代码生成错误:
PHP Fatal error: Class 'B' not found in /tmp/a.php on line 10