一周前我写了一个代码,它工作正常。但是今天当我检查它时,它给了我一些问题,比如
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 链接
有人可以帮我解决一下突然发生的事情,它不起作用。
谢谢