Uncaught Error: Class 'Google\AdsApi\Examples\AdWords\v201809\Reporting\DOMDocument' not found
Uncaught Error: Class 'Google\AdsApi\Examples\AdWords\v201809\Reporting\DOMDocument' not found
我安装了 php-xml,并且它与其他 php 文件一起运行良好,使用以下代码在网站上显示 xml:
$doc = new DOMDocument();
$doc->loadXML(html_entity_decode($xml), LIBXML_NOXMLDECL);
echo $doc->saveXML();
但它在 Google AdWords 报告 API 中不起作用。它显然与 namespace Google\AdsApi\Examples\AdWords\v201809\Reporting;
有关 我不熟悉 PHP 并且想知道如何让这个 DOMDocument
在 Reporting
命名空间内工作。谢谢。
您需要在 DOMDocument
之前添加反斜杠 \
以从全局命名空间加载 class。否则 php 在您当前的命名空间中搜索 DOMDocument class。
如果您需要更多相关信息,您可能需要查看 php documentation for global namespaces:
$doc = new \DOMDocument();
我安装了 php-xml,并且它与其他 php 文件一起运行良好,使用以下代码在网站上显示 xml:
$doc = new DOMDocument();
$doc->loadXML(html_entity_decode($xml), LIBXML_NOXMLDECL);
echo $doc->saveXML();
但它在 Google AdWords 报告 API 中不起作用。它显然与 namespace Google\AdsApi\Examples\AdWords\v201809\Reporting;
有关 我不熟悉 PHP 并且想知道如何让这个 DOMDocument
在 Reporting
命名空间内工作。谢谢。
您需要在 DOMDocument
之前添加反斜杠 \
以从全局命名空间加载 class。否则 php 在您当前的命名空间中搜索 DOMDocument class。
如果您需要更多相关信息,您可能需要查看 php documentation for global namespaces:
$doc = new \DOMDocument();