即使我们只调用一次函数,使用关键字 我也可以使用 在我看来,第二个版本更清晰,但如果我使用<是否有任何性能问题 代码>使用 code>仅用于一次调用? p>
div> use code>也不好吗?
E.g。 我有自己的typo3扩展,我在我的控制器中访问一个typo3核心函数,但只有一次。 p>
$ message = \ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility :: makeInstance('TYPO3 \\ CMS \\ Core \\ Mail \\ MailMessage');
code> pre>
use 代码>: p>
使用\ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility;
...
$ message = GeneralUtility :: makeInstance('TYPO3 \\ CMS \ \ Core \\ Mail \\ MailMessage');
code> pre>
Is it bad to use the keyword use
even though we only call a function once?
E.g. I have my own typo3 extension, and I am accessing a typo3 core function in my controller, but only once.
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
I could also make use of use
:
use \TYPO3\CMS\Core\Utility\GeneralUtility;
...
$message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
In my opinion the second variant is much cleaner, but are there any performance issues if I make use of use
only for one call?