未捕获的错误:找不到类"Google \ AdsApi \ Examples \ AdWords \ v201809 \ Reporting \ DOMDocument" [英] Uncaught Error: Class 'Google\AdsApi\Examples\AdWords\v201809\Reporting\DOMDocument' not found
问题描述
我已经安装了php-xml,并且可以使用以下代码与其他php文件一起正常运行,以在网站上显示xml:
I have php-xml installed and it runs fine with other php files using the following code to display xml on a web site:
$doc = new DOMDocument();
$doc->loadXML(html_entity_decode($xml), LIBXML_NOXMLDECL);
echo $doc->saveXML();
但是它不能在Google AdWords Report API中使用.显然,它与我不熟悉PHP的namespace Google\AdsApi\Examples\AdWords\v201809\Reporting;
有关,想知道如何在Reporting
命名空间中使用此DOMDocument
.谢谢.
But it won't work in Google AdWords Report API. It obviously has something to do with the namespace Google\AdsApi\Examples\AdWords\v201809\Reporting;
I am not familiar with PHP and wonder how to get this DOMDocument
working inside the Reporting
namespace. Thanks.
推荐答案
您需要在DOMDocument
之前添加反斜杠\
,以从全局命名空间中加载类.否则,php将在您当前的名称空间中搜索DOMDocument类.
You need to add a backslash \
before the DOMDocument
to load the class from the global namespace. Otherwise php searches for the DOMDocument class in your current namespace.
If you need more information about this, you may want to take a look at the php documentation for global namespaces:
$doc = new \DOMDocument();
这篇关于未捕获的错误:找不到类"Google \ AdsApi \ Examples \ AdWords \ v201809 \ Reporting \ DOMDocument"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!