<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Azone&#039;s Blog &#187; php数组访问对象</title>
	<atom:link href="http://www.firestudio.cn/tag/php%e6%95%b0%e7%bb%84%e8%ae%bf%e9%97%ae%e5%af%b9%e8%b1%a1/feed" rel="self" type="application/rss+xml" />
	<link>http://www.firestudio.cn</link>
	<description>用到一点记录一点。</description>
	<lastBuildDate>Thu, 01 Dec 2011 03:20:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>通过数组方式访问PHP对象属性</title>
		<link>http://www.firestudio.cn/2010/05/21/162.html</link>
		<comments>http://www.firestudio.cn/2010/05/21/162.html#comments</comments>
		<pubDate>Fri, 21 May 2010 03:59:49 +0000</pubDate>
		<dc:creator>Yozone Wong</dc:creator>
				<category><![CDATA[PHP编程]]></category>
		<category><![CDATA[应用技巧]]></category>
		<category><![CDATA[ArrayAcces]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php数组访问对象]]></category>

		<guid isPermaLink="false">http://www.firestudio.cn/?p=162</guid>
		<description><![CDATA[以前看到过新版本的Symfony的Form文档，在类中可以通过$this['key']的方法来访问当前对象中的widgets，我一直很诧异，为什么可以这样用呢？我试验过很多方法都没成功，今天终于找到答案了。 方法其实很简单，需要在类中继承PHP预定义接口ArrayAccess，并且包含offsetGet, offsetSet, offsetExists和offsetUnset四个方法就可以实现上述功能了。下面来举个例子： &#38;lt; ?php class test implements ArrayAccess &#123; private $_result = array&#40;'name' =&#38;gt; 'Yozone', 'age' =&#38;gt; '24'&#41;; public function offsetGet&#40;$key&#41; &#123; return $this-&#38;gt;_result&#91;$key&#93;; &#125; public function offsetExists&#40;$key&#41; &#123; return isset&#40;$this-&#38;gt;_result&#91;$key&#93;&#41;; &#125; public function offsetSet&#40;$key, $value&#41; &#123; $this-&#38;gt;_result&#91;$key&#93; = $value; &#125; public function offsetUnset&#40;$key&#41; &#123; unset&#40;$key&#41;; &#125; public function getName&#40;&#41; &#123; return $this&#91;'name'&#93;; [...]]]></description>
		<wfw:commentRss>http://www.firestudio.cn/2010/05/21/162.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

