这是我的代码和我遇到的问题:
// index.php
require "/var/www/functions.php";
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
$microsoftGraph = new Graph();
test();
// functions.php
function test($microsoftGraph) {
$create = $microsoftGraph->createRequest('POST', $create)
->setReturnType(Model\Event::class) // This is where I'm having a problem
->execute();
}
错误是说:
PHP 致命错误:未捕获的错误:在...中找不到类“事件”
但是......如果我use像这样把它放在我的functions.php中,它可以工作:
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
function test($microsoftGraph) {
$create = $microsoftGraph->createRequest('POST', $create)
->setReturnType(Model\Event::class) // This is where I'm having a problem
->execute();
}
但我怎样才能“通过”或不放入use文件中functions.php?