Fatal Error:can ' t use object ' StdClass ' as array master help look depressed dead
This post was last edited by baikujingling on 2014-09-15 20:04:51
The 39 lines of code are:$item = $resp ["item_list"] [' Sp_item '][0];
--------------------------------------------------------------------------------------------------------------- --------------
the error message is:
Com.caucho.quercus.quercuserrorexception:e:\tae_svn\tae_sdk\apps\ceshi7\admin\core\goodscreate.php:39:fatal Error:can ' t use object ' StdClass ' as array
-----------------------------------------------------------------------------------------------------------
the front and rear codes are:
if ($dopost = = ' Caiji ')
{
if ($numIid! = "" "&& Rrulenum ($numIid))
{
$c = new Topclient;
$c->appkey = $appkey; Top Appkey
$c->secretkey = $secretKey; Top Secretkey
Instantiate the request class for the specific API
$req = new Spiteminfolistgetrequest;
$req->setid ($numIid);
$req->setsitekey (' 3zzd10741k7259kez673850e4346d6l1 ');
$resp = $c->execute ($req);
Print_r ($RESP);
$item = $resp ["item_list"] [' Sp_item '][0];
if ($item)
{
$detail _url = $item ["Item_url"]; Product Links
$num _iid = $item ["item_id"]; Product ID
$title = $item ["title"]; Product Title
$nick = $item ["Nick"]; Seller Nickname
$pic _url = "http://img1.tbcdn.cn/tfscom/". $item ["Pic_url"]; Main product Map
$price = $item ["Price"]; Original Price of commodity
$freight _payer = $item ["Freight_payer"]; Canceled the
$freight _payer = "seller";//temporary is set to the package mail
$sid = $item ["seller_id"]; Seller Digital ID
$num = 1000; Temporary use of goods quantity
$item _imgs = $item ["Itemimgs"]; Product Picture List
}
Else
$createMessage = ' There is no such product ';
Print_r ($RESP);
}
Else
{
$createMessage = "Commodity id" cannot be empty "and" must be a number ". ";
}
}
------to solve the idea----------------------
Young man, think of course is taboo!
Landlord only
$resp = $c->execute ($req);
Print_r ($RESP);
$item = $resp ["item_list"] [' Sp_item '][0];
Did not give the results of Print_r ($RESP)
How can you conclude that he is the result of JSON decoding?
I use JSON to simulate a wrong scene, does not mean that the real situation of the landlord
It just means that this kind of error may occur under what circumstances.
And I said the reason: you're accessing the object as an array.
References:
Quote: References:
I'm helping the landlord to analyze the cause of the error, you pounded what mess
Quote: References:
Quote: References:
By
$o = Json_decode (' {"a": {"B": [[+]}} ');
echo $o [' a '] [' B '][0];
Error Fatal error:cannot Use object of type StdClass as array
You can infer that you are accessing the object as an array.
To do this
Echo $o->a->b[0];
You can do that.
$o = Json_decode (' {"a": {"B": [[+]}} ', true);
echo $o [' a '] [' B '][0];
You didn't say the reason ...
Should be json_decode always return a PHP object instead of an array
------to solve the idea----------------------
Citation:
young man, think of course is taboo!
Landlord only
$resp = $c->execute ($req);
Print_r ($RESP);
$item = $resp ["item_list"] [' Sp_item '][0];
Did not give the results of Print_r ($RESP)
How can you conclude that he is the result of JSON decoding?
I use JSON to simulate a wrong scene, does not mean that the real situation of the landlord
It just means that this kind of error may occur under what circumstances.
And I said the reason: you're accessing the object as an array.
Quote: References: