日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

php stdclass,php – 处理stdClass对象

發(fā)布時(shí)間:2025/4/16 php 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php stdclass,php – 处理stdClass对象 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

谷歌搜索了一段時(shí)間后,我發(fā)現(xiàn)我可以使用此代碼進(jìn)行谷歌搜索:

$text=$_GET['text'];

$results=file_get_contents("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" . $text);

// Too lazy to use cURL

$results=json_decode($results);

問題是$results實(shí)際上是一個(gè)對(duì)象(stdClass),并且像處理數(shù)組一樣處理它不起作用(即$results [“responseData”]).這是完整的var_dump:

object(stdClass)#1 (3) {

["responseData"]=>

object(stdClass)#2 (2) {

["results"]=>

array(4) {

[0]=>

object(stdClass)#3 (8) {

["GsearchResultClass"]=>

string(10) "GwebSearch"

["unescapedUrl"]=>

string(51) "http://www.urbandictionary.com/define.php?term=lulz"

["url"]=>

string(55) "http://www.urbandictionary.com/define.php%3Fterm%3Dlulz"

["visibleUrl"]=>

string(23) "www.urbandictionary.com"

["cacheUrl"]=>

string(73) "http://www.google.com/search?q=cache:9eN_paaTATEJ:www.urbandictionary.com"

["title"]=>

string(29) "Urban Dictionary: lulz"

["titleNoFormatting"]=>

string(22) "Urban Dictionary: lulz"

["content"]=>

string(159) "Beginning as a plural variant of lol, Lulz was originally an exclamation but is now often used as a noun meaning interesting or funny internet cont..."

}

[1]=>

object(stdClass)#4 (8) {

["GsearchResultClass"]=>

string(10) "GwebSearch"

["unescapedUrl"]=>

string(34) "http://en.wiktionary.org/wiki/lulz"

["url"]=>

string(34) "http://en.wiktionary.org/wiki/lulz"

["visibleUrl"]=>

string(17) "en.wiktionary.org"

["cacheUrl"]=>

string(67) "http://www.google.com/search?q=cache:ksdO4S_AefUJ:en.wiktionary.org"

["title"]=>

string(24) "lulz - Wiktionary"

["titleNoFormatting"]=>

string(17) "lulz - Wiktionary"

["content"]=>

string(173) "Like a€?Hakuna matataa€ in The Lion King, a€?lulza€ is not just a word, but a philosophy. [...] Anonymous has made campaigning sexy for the first time since 1968."

}

[2]=>

object(stdClass)#5 (8) {

["GsearchResultClass"]=>

string(10) "GwebSearch"

["unescapedUrl"]=>

string(51) "http://knowyourmeme.com/memes/i-did-it-for-the-lulz"

["url"]=>

string(51) "http://knowyourmeme.com/memes/i-did-it-for-the-lulz"

["visibleUrl"]=>

string(16) "knowyourmeme.com"

["cacheUrl"]=>

string(66) "http://www.google.com/search?q=cache:ITVRlkQkfckJ:knowyourmeme.com"

["title"]=>

string(45) "I Did It for the Lulz | Know Your Meme"

["titleNoFormatting"]=>

string(38) "I Did It for the Lulz | Know Your Meme"

["content"]=>

string(173) "About I Did it for the Lulz (also known as 4 the lulz) is a popular catchphrase used to express that one carried out a specific action for the sake of perso."

}

[3]=>

object(stdClass)#6 (8) {

["GsearchResultClass"]=>

string(10) "GwebSearch"

["unescapedUrl"]=>

string(56) "http://www.internetslang.com/LULZ-meaning-definition.asp"

["url"]=>

string(56) "http://www.internetslang.com/LULZ-meaning-definition.asp"

["visibleUrl"]=>

string(21) "www.internetslang.com"

["cacheUrl"]=>

string(71) "http://www.google.com/search?q=cache:UNXME3GmS-AJ:www.internetslang.com"

["title"]=>

string(88) "What does LULZ mean? - LULZ Definition - Meaning of LULZ ..."

["titleNoFormatting"]=>

string(60) "What does LULZ mean? - LULZ Definition - Meaning of LULZ ..."

["content"]=>

string(185) "This Internet Slang page is designed to explain what the meaning of LULZ is. The slang word / acronym / abbreviation LULZ means... . Internet Slang. A list of ..."

}

}

["cursor"]=>

object(stdClass)#7 (6) {

["resultCount"]=>

string(9) "1,080,000"

["pages"]=>

array(8) {

[0]=>

object(stdClass)#8 (2) {

["start"]=>

string(1) "0"

["label"]=>

int(1)

}

[1]=>

object(stdClass)#9 (2) {

["start"]=>

string(1) "4"

["label"]=>

int(2)

}

[2]=>

object(stdClass)#10 (2) {

["start"]=>

string(1) "8"

["label"]=>

int(3)

}

[3]=>

object(stdClass)#11 (2) {

["start"]=>

string(2) "12"

["label"]=>

int(4)

}

[4]=>

object(stdClass)#12 (2) {

["start"]=>

string(2) "16"

["label"]=>

int(5)

}

[5]=>

object(stdClass)#13 (2) {

["start"]=>

string(2) "20"

["label"]=>

int(6)

}

[6]=>

object(stdClass)#14 (2) {

["start"]=>

string(2) "24"

["label"]=>

int(7)

}

[7]=>

object(stdClass)#15 (2) {

["start"]=>

string(2) "28"

["label"]=>

int(8)

}

}

["estimatedResultCount"]=>

string(7) "1080000"

["currentPageIndex"]=>

int(0)

["moreResultsUrl"]=>

string(76) "http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=lulz"

["searchResultTime"]=>

string(4) "0.23"

}

}

["responseDetails"]=>

NULL

["responseStatus"]=>

int(200)

}

那么,關(guān)于如何讀取結(jié)果數(shù)組的任何線索? (除了$results [“responseData”]之外沒有嘗試過,因?yàn)槲抑皬奈词褂眠^JSON.)

總結(jié)

以上是生活随笔為你收集整理的php stdclass,php – 处理stdClass对象的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。