- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
一周前我写了一个代码,它运行良好。但是今天当我检查它时,它给了我一些问题,比如
Warning: get_class() expects parameter 1 to be object, array given in /home/ccc/public_html/horoscope/xml2json.php on line 182
Warning: get_class() expects parameter 1 to be object, string given in /home/ccc/public_html/horoscope/xml2json.php on line 182
Warning: get_class() expects parameter 1 to be object, string given in /home/ccc/public_html/horoscope/xml2json.php on line 182
Warning: get_class() expects parameter 1 to be object, string given in /home/ccc/public_html/horoscope/xml2json.php on line 182
Warning: get_class() expects parameter 1 to be object, string given in /home/ccc/public_html/horoscope/xml2json.php on line 182
我的部分代码是
$currentDate = date("n/j/Y");
echo($hdate);
require_once("xml2json.php");
$testXmlFile = "http://www.findyourfate.com/rss/horoscope-astrology-feed.asp?mode=view&todate=$currentDate";
echo($testXmlFile);
$xmlStringContents = file_get_contents($testXmlFile);
$jsonContents = "";
$jsonContents = xml2json::transformXmlStringToJson($xmlStringContents);
$obj =json_decode($jsonContents);
$rows = array();
foreach($obj->rss->channel->item as $item)
xml2json中的182行是
if (get_class($simpleXmlElementObject) == SIMPLE_XML_ELEMENT_PHP_CLASS) {
// Get a copy of the simpleXmlElementObject
$copyOfsimpleXmlElementObject = $simpleXmlElementObject;
// Get the object variables in the SimpleXmlElement object for us to iterate.
$simpleXmlElementObject = get_object_vars($simpleXmlElementObject);
}
这里是 simpleXMLElement 对象的 var_dump 的 pastebin 链接
谁能帮我解决突然发生的问题,它不起作用。
谢谢
最佳答案
只需添加 is_object 检查
if (is_object($simpleXmlElementObject) && get_class($simpleXmlElementObject) == SIMPLE_XML_ELEMENT_PHP_CLASS) {
关于php - 警告 : get_class() expects parameter 1 to be object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16292949/
我正在做一个 Zend 项目,自从我接触 Zend 以来已经超过 12 个月了,我在我的一个函数上遇到了一个错误,我不知道为什么,我认为这可能是网站的问题最初是在早期版本的 PHP (5.2) 中构建
我正在做一个 Zend 项目,自从我接触 Zend 以来已经超过 12 个月了,我在我的一个函数上遇到了一个错误,我不知道为什么,我认为这可能是网站的问题最初是在早期版本的 PHP (5.2) 中构建
在PHP中get_called_class()有什么区别?和 get_class($this)在实例中使用时? 例子: class A { function dump() {
你能解释一下 get_class($instance) 和 ClassName::class 之间的区别吗?
使用 PHPUnit 和模拟对象,我正在尝试测试一些代码,这些代码使用 get_class 来确定对象是否包含在过滤器中。 这是要测试的类: class BlockFilter implements
我有一些代码: get_class($foo) == Bar::class 不同于: $foo instanceof Bar::class 出现这种情况的可能原因是什么? 最佳答案 一个对象是给定 C
我有一些代码: get_class($foo) == Bar::class 不同于: $foo instanceof Bar::class 出现这种情况的可能原因是什么? 最佳答案 一个对象是给定 C
给定一个像这样的类 function FooClass() { this.data = { foo: null, bar: null, } } 及其实例
一周前我写了一个代码,它运行良好。但是今天当我检查它时,它给了我一些问题,比如 Warning: get_class() expects parameter 1 to be object, array
当我尝试在新的本地机器上部署 Symfony 2.8 项目时,我在多个代码位置遇到了这个错误: "Warning: get_class() expects parameter 1 to be obje
在 app/Exceptions/Handler.php 中的以下代码中,第一个不起作用,但第二个起作用。 dd(get_class($exception));输出“Illuminate\Databa
我见过几个线程,人们在其中询问如何在 PHP 中获取类或对象的名称。但是,我在任何地方都看不到所解释的各种可能性之间的区别。我希望这里有人可以帮助我。 所以为了得到被调用类的类名,我知道两种可能: g
我是一名优秀的程序员,十分优秀!