FatalError: Can & # x27; tuseobject & # x27; stdClass & # x27; master asarray helps you to see if it is depressing. This post was last written by mongokujingling at 2014-09-1520: 04: 51 edit 39 lines of code: & nbsp; $ item $ resp [item_l Fatal Error: Can't use object 'stdclass' as the array master to help you see it is depressed
This post was last edited by mongokujingling at 20:04:51, January 15 ,.
39 lines of code: $ item = $ resp ["item_list"] ['sp _ item'] [0];
Bytes -----------------------------------------------------------------------------------------------------------------------------
Error message:
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
Bytes -----------------------------------------------------------------------------------------------------------
Before and after the code is:
If ($ dopost = 'caiji ')
{
If ($ numIid! = "" & RRuleNum ($ numIid ))
{
$ C = new TopClient;
$ C-> appkey = $ appkey; // top appkey
$ C-> secretKey = $ secretKey; // top secretkey
// Instantiate the Request class corresponding to a specific API
$ Req = new SpItemInfoListGetRequest;
$ Req-> setId ($ numIid );
$ Req-> setSiteKey ('3zzd10741k7259kez673850e4366d6l1 ');
$ Resp = $ c-> execute ($ req );
// Print_r ($ resp );
$ Item = $ resp ["item_list"] ['sp _ item'] [0];
If ($ item)
{
$ Detail_url = $ item ["item_url"]; // product link
$ Num_iid = $ item ["item_id"]; // item ID
$ Title = $ item ["title"]; // item title
$ Nick = $ item ["nick"]; // seller nickname
$ Pic_url = "http://img1.tbcdn.cn/tfscom/". $ item ["pic_url"]; // product master diagram
$ Price = $ item ["price"]; // original price of the product
// $ Freight_payer = $ item ["freight_payer"]; // canceled
$ Freight_payer = "seller"; // you can set it to shipping on a temporary basis.
$ Sid = $ item ["seller_id"]; // seller's digital ID
$ Num = 1000; // temporary use of item quantity
$ Item_imgs = $ item ["itemImgs"]; // item image list
}
Else
$ CreateMessage = 'This item does not exist ';
// Print_r ($ resp );
}
Else
{
$ CreateMessage = "product ID [cannot be blank] and [must be a number ]. ";
}
}
------ Solution ----------------------
Young people, it's a secret!
Only
$ Resp = $ c-> execute ($ req );
// Print_r ($ resp );
$ Item = $ resp ["item_list"] ['sp _ item'] [0];
The result of print_r ($ resp) is not provided.
How can you determine that it is the result of json decoding?
I use json to simulate an error scenario, which does not indicate the real situation of the landlord.
It only indicates the circumstances in which such errors may occur.
I also said the reason: you have accessed the object as an array.
Reference:
Quote: reference:
I am helping the landlord analyze the cause of the error.
Quote: reference:
Quote: reference:
By
$ O = json_decode ('{"a": {"B": [1, 2, 3]}');
Echo $ o ['A'] ['B'] [0];
Error Fatal error: Cannot use object of type stdClass as array
We can infer that you have accessed the object as an array.
To do this
Echo $ o-> a-> B [0];
You can also
$ O = json_decode ('{"a": {"B": [1, 2, 3]}', true );
Echo $ o ['A'] ['B'] [0];
You didn't say the reason .......
It should be that json_decode always returns a PHP object instead of an array
------ Solution ----------------------
Reference:
Young people, it's a secret!
Only
$ Resp = $ c-> execute ($ req );
// Print_r ($ resp );
$ Item = $ resp ["item_list"] ['sp _ item'] [0];
The result of print_r ($ resp) is not provided.
How can you determine that it is the result of json decoding?
I use json to simulate an error scenario, which does not indicate the real situation of the landlord.
It only indicates the circumstances in which such errors may occur.
I also said the reason: you have accessed the object as an array.
Quote: reference: