【发布时间】:2014-09-15 17:56:47
【问题描述】:
我从未在任何地方见过这种结构,所以我想知道这样的表达式是否有问题:
if (condition) {
use Symfony\Component\HttpFoundation\Response;
}
【问题讨论】:
-
你为什么需要它?
-
使用条件的目的是什么?
use不包括任何东西。 -
根据文档
the importing is done at compile time and not runtime,所以你不应该这样做。 php.net/manual/en/language.namespaces.importing.php -
看这个 php.net There is a similar demo about namespace usage.
-
这个想法是为了避免加载不必要的代码,所以我认为@Debflav 解释了它。
标签: php namespaces conditional