以下是变量$ x(youtube video)的转储。
但是我想访问媒体$ title,但显然当我尝试
时$ x轴>媒体$标题 - > $吨
它不起作用。有关如何访问YouTube视频标题的任何建议吗?
stdClass Object (
[version] => 1.0
[encoding] => UTF-8
[entry] => stdClass Object ( [xmlns] => http://www.w3.org/2005/Atom [xmlns$media] => http://search.yahoo.com/mrss/ [xmlns$gd] => http://schemas.google.com/g/2005 [xmlns$yt] => http://gdata.youtube.com/schemas/2007 [id] => stdClass Object ( [$t] => http://gdata.youtube.com/feeds/api/videos/OQ14NjbEXJM ) [published] => stdClass Object ( [$t] => 2006-10-01T23:21:06.000Z ) [updated] => stdClass Object ( [$t] => 2009-08-25T07:34:28.000Z ) [category] => Array ( [0] => stdClass Object ( [scheme] => http://schemas.google.com/g/2005#kind [term] => http://gdata.youtube.com/schemas/2007#video ) [1] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/categories.cat [term] => Howto [label] => Howto & Style ) [2] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => tutorial ) [3] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => php ) [4] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => sql ) [5] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => mysql ) [6] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => phpmyadmin ) [7] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => lgo666 ) [8] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => computers ) [9] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => video ) [10] => stdClass Object ( [scheme] => http://gdata.youtube.com/schemas/2007/keywords.cat [term] => sexy ) ) [title] => stdClass Object ( [$t] => PHP Tutorial // User Registration w/ SQL [type] => text ) [content] => stdClass Object ( [$t] => PLEASE CHECK OUT THE SECOND VIDEO OF THIS A quick and easy user registration using php, sql and phpmyadmin. For full size and source codes: http://www.neoblob.com/phpsquad/tuts/php/1/ SQL: CREATE TABLE `user` ( `id` int(10) unsigned NOT NULL auto_increment, `username` varchar(20) NOT NULL default '', `password` varchar(50) NOT NULL default '', `email` varchar(40) NOT NULL default '', `ip` varchar(20) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; [type] => text ) [link] => Array ( [0] => stdClass Object ( [rel] => alternate [type] => text/html [href] => http://www.youtube.com/watch?v=OQ14NjbEXJM ) [1] => stdClass Object ( [rel] => http://gdata.youtube.com/schemas/2007#video.responses [type] => application/atom+xml [href] => http://gdata.youtube.com/feeds/api/videos/OQ14NjbEXJM/responses ) [2] => stdClass Object ( [rel] => http://gdata.youtube.com/schemas/2007#video.related [type] => application/atom+xml [href] => http://gdata.youtube.com/feeds/api/videos/OQ14NjbEXJM/related ) [3] => stdClass Object ( [rel] => http://gdata.youtube.com/schemas/2007#mobile [type] => text/html [href] => http://m.youtube.com/details?v=OQ14NjbEXJM ) [4] => stdClass Object ( [rel] => self [type] => application/atom+xml [href] => http://gdata.youtube.com/feeds/api/videos/OQ14NjbEXJM ) ) [author] => Array ( [0] => stdClass Object ( [name] => stdClass Object ( [$t] => lifeg0eson666 ) [uri] => stdClass Object ( [$t] => http://gdata.youtube.com/feeds/api/users/lifeg0eson666 ) ) ) [gd$comments] => stdClass Object ( [gd$feedLink] => stdClass Object ( [href] => http://gdata.youtube.com/feeds/api/videos/OQ14NjbEXJM/comments [countHint] => 365 ) ) [media$group] => stdClass Object ( [media$category] => Array ( [0] => stdClass Object ( [$t] => Howto [label] => Howto & Style [scheme] => http://gdata.youtube.com/schemas/2007/categories.cat ) ) [media$content] => Array ( [0] => stdClass Object ( [url] => http://www.youtube.com/v/OQ14NjbEXJM&f=videos&app=youtube_gdata [type] => application/x-shockwave-flash [medium] => video [isDefault] => true [expression] => full [duration] => 980 [yt$format] => 5 ) [1] => stdClass Object ( [url] => rtsp://rtsp2.youtube.com/CiILENy73wIaGQmTXMQ2NngNORMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp [type] => video/3gpp [medium] => video [expression] => full [duration] => 980 [yt$format] => 1 ) [2] => stdClass Object ( [url] => rtsp://rtsp2.youtube.com/CiILENy73wIaGQmTXMQ2NngNORMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp [type] => video/3gpp [medium] => video [expression] => full [duration] => 980 [yt$format] => 6 ) ) [media$description] => stdClass Object ( [$t] => PLEASE CHECK OUT THE SECOND VIDEO OF THIS A quick and easy user registration using php, sql and phpmyadmin. For full size and source codes: http://www.neoblob.com/phpsquad/tuts/php/1/ SQL: CREATE TABLE `user` ( `id` int(10) unsigned NOT NULL auto_increment, `username` varchar(20) NOT NULL default '', `password` varchar(50) NOT NULL default '', `email` varchar(40) NOT NULL default '', `ip` varchar(20) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; [type] => plain ) [media$keywords] => stdClass Object ( [$t] => tutorial, php, sql, mysql, phpmyadmin, lgo666, computers, video, sexy ) [media$player] => Array ( [0] => stdClass Object ( [url] => http://www.youtube.com/watch?v=OQ14NjbEXJM ) ) [media$thumbnail] => Array ( [0] => stdClass Object ( [url] => http://i.ytimg.com/vi/OQ14NjbEXJM/2.jpg [height] => 90 [width] => 120 [time] => 00:08:10 ) [1] => stdClass Object ( [url] => http://i.ytimg.com/vi/OQ14NjbEXJM/1.jpg [height] => 90 [width] => 120 [time] => 00:04:05 ) [2] => stdClass Object ( [url] => http://i.ytimg.com/vi/OQ14NjbEXJM/3.jpg [height] => 90 [width] => 120 [time] => 00:12:15 ) [3] => stdClass Object ( [url] => http://i.ytimg.com/vi/OQ14NjbEXJM/0.jpg [height] => 240 [width] => 320 [time] => 00:08:10 ) ) [media$title] => stdClass Object ( [$t] => PHP Tutorial // User Registration w/ SQL [type] => plain ) [yt$duration] => stdClass Object ( [seconds] => 980 ) ) [gd$rating] => stdClass Object ( [average] => 3.8587787 [max] => 5 [min] => 1 [numRaters] => 262 [rel] => http://schemas.google.com/g/2005#overall ) [yt$statistics] => stdClass Object ( [favoriteCount] => 549 [viewCount] => 144308 ) ) )
答案 0 :(得分:7)
尝试
$x->{'media$title'}->{'$t'}
如果您需要访问使用非法字符的PHP对象中的成员(即$符号,还有空格等),您可以执行$ obj-> {'成员名称'}技巧来访问它