未捕获的错误:找不到类"Google \ AdsApi \ Examples \ AdWords \ v201809 \ Reporting \ DOMDocument" [英] Uncaught Error: Class 'Google\AdsApi\Examples\AdWords\v201809\Reporting\DOMDocument' not found

查看:64
本文介绍了未捕获的错误:找不到类"Google \ AdsApi \ Examples \ AdWords \ v201809 \ Reporting \ DOMDocument"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆