How to use two namespaces in one file yii2?

2019-08-17 06:32发布

问题:

How can use two namespaces in one file yii2?

I need to use

namespace backend/controllers;

namespace MongoDb;

回答1:

You can achieve it like this:

<?php
namespace backend/controllers;

{ /* Code goes here */ }
{ /* Some more code */  }

namespace MongoDb;

{ /* Code goes here */ }
{ /* Some more code */  }
?>

http://php.net/manual/en/language.namespaces.definitionmultiple.php