这是我的代码以及正在运行的代码:
// 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致命错误:未捕获的错误:在...中找不到类'Event'。
但是... ,如果我将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
文件中?