我不知道這是否是專門Symfony2.4.0相關的,但是當我有一個Symfony2.4.0新反斜槓類名()
<?php
namespace Wow\DogeBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class ProbeCommand extends ContainerAwareCommand
{
protected function configure()
{
$this ->setName('a:name')
->setDescription('wow');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$whenithappened = new \DateTime();
//more code
}
}
此代碼的工作好了,但到底是什麼反斜槓在DateTime()的前面是什麼意思?只要我刪除反向斜槓我得到這個錯誤:
PHP Fatal error: Class 'Wow\DogeBundle\Command\DateTime'
是否反向斜線某種逃避回到根命名空間?我可以有這個代碼
<?php
$whenithappened = new \DateTime();
var_dump($whenithappened);
?>
它可以在DateTime()
之前有或沒有反斜槓正常工作。
[Backslash in PHP中的可能的重複 - 這是什麼意思?](http://stackoverflow.com/questions/10788400/backslash-in-php-what-does-it-mean),http:// stackoverflow.com/questions/4790020/what-does-backslash-do-php5-3,http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php –
我原本有這個問題張貼作爲轉發斜槓,所以谷歌搜索答案沒有結果。多謝你們。 –