<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[零度空间]]></title> 
<link>http://www.206c.net/blog/index.php</link> 
<description><![CDATA[笑看人生]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[零度空间]]></copyright>
<item>
<link>http://www.206c.net/blog/post/59/</link>
<title><![CDATA[用正确的小汽车对象学习和熟悉类的概念]]></title> 
<author>零度溫柔 &lt;nickdraw@qq.com&gt;</author>
<category><![CDATA[PHP资源]]></category>
<pubDate>Fri, 10 Jul 2009 17:08:14 +0000</pubDate> 
<guid>http://www.206c.net/blog/post/59/</guid> 
<description>
<![CDATA[ 
	我们的小车可不是随便让人图图颜色就完了（只能图颜色的是废车）。我们的这个小车不但能够到处乱跑，而且装备了高级GPS全球定位系统，油表，里程表。由于使用了面向对象的技术，驾驭这样的一部小汽车一点都不难。<br/><br/>举例子首先要提供一些背景材料。我们有一辆小汽车，可以在一个拥有xy坐标的地图上按照东南西北方向任意的行驶，你可以设定小车行驶的方向和距离，小车会向你汇报它的坐标位置。<br/><br/>其实学习类应该和我们学习其它事物一样，从学习使用开始，然后再学习他的原理。所以我们先来熟悉一下如何正确驾驶这样的一个小汽车：<br/><br/><textarea name="code" class="php" rows="15" cols="100"><?php
$startPoint = & new Position(3,9); //初始一个出发点坐标x=3,y=9 

$myCar = & new Car(500,$startPoint); //我得到一个新的小车，新车初始燃油 500 升，出发地点$startPoint。 

$myCar->setHeading('s'); //给小车设定方向 s:南方 n:北方 w:西方 e:东方。 

if($myCar->run(100)) //然后让小车跑100公里，如果顺利完成任务显示燃油量。如果半途而废，我们显示警报信息。 
&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;print('<br/><b>小车一切正常，目前还有燃油：'.$myCar->getGas().'</b>');//获得燃油数 
&#125; 
else 
&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;print('<br/><b>小车出问题了: '.$myCar->getWarning().'</b>');//显示警报信息 
&#125; 

$myPosition=$myCar->getPosition();//获得小车当前的位置 

print('<br/>我的小车现在<br/> X:'.$myPosition->getX().'Y:'.$myPosition->getY());//显示小车的坐标位置
?> 
</textarea><br/><br/>先给自己制造一个小汽车，并且给他装备上一个定位对象 Position。 然后设定方向， 然后让小车奔跑。 最后检查并输出小车的方位。 复杂么？很难理解吗？ 虽然这里我们用到了两个对象（类）：Car 和 Position 但是我相信即使是初学者也不会觉得上面的代码很困难。<br/><br/>我们学会如何开车了以后，再来仔细看一看这个小车对象是怎样工作的。定义一个对象其实很简单只需要 用一个关键字class 和一对&#123;&#125;就可以了，所以我们这样定义这两个对象：<br/><br/>class Car &#123;&#125;<br/>class Position&#123;&#125;<br/>当然，仅仅这样的两个类什么也做不了，我们还需要给他们增加一些功能，先从小汽车开始，我们需要能够给小车设定方向并且让小车奔跑所以我们增加两个方法，也就是2个函数只不过这两个函数包含在小车对象内只有通过小车对象才可以使用。<br/> <br/><br/>setHeading() <br/>run() <br/>class Car<br/>&#123;<br/>&nbsp;&nbsp;function setHeading($direction)<br/>&nbsp;&nbsp;&#123;<br/><br/>&nbsp;&nbsp;&#125;<br/><br/>&nbsp;&nbsp;function run($km)<br/>&nbsp;&nbsp;&#123;<br/><br/>&nbsp;&nbsp;&#125;<br/>&#125;<br/>特别提示：设计一个良好的类的窍门是从如何使用它下手，也就是说先考虑这个对象应当有哪些方法，而不是先确定它有哪些属性。<br/>为了更好的了解小车的状况我们还需要这些方法：<br/><br/>getGas() 获得小车当前的燃油数 <br/>getPosition() 获得小车当前的位置 <br/>getWarning() 警报信息 <br/>为了完成这些功能我们的小车还需要自己的油表，警报消息，和定位仪。我们把这些也添加到 Car 类中，同时我们还给这个类增加了一个初始化的函数 这个函数名字和类的名字一样，这样就有了一个大体的框架。<br/><br/><textarea name="code" class="php" rows="15" cols="100"><?php
class Car 
&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 小车的汽油量 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var 
&nbsp;&nbsp;&nbsp;&nbsp;*@access 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $gas; 

&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 里程记录 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var 
&nbsp;&nbsp;&nbsp;&nbsp;*@access 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $meter; 

&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 车的位置（由GPS自动控制） 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var Object position 
&nbsp;&nbsp;&nbsp;&nbsp;*@access private 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $position; 
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 发动机每1公里耗油量，这个车是0.1升 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var Integer 
&nbsp;&nbsp;&nbsp;&nbsp;*@access private 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $engine=0.1; 

&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 警报信息 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var 
&nbsp;&nbsp;&nbsp;&nbsp;*@access 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $warning; 
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;小车的初始化。新车出场当然要 
&nbsp;&nbsp;&nbsp;&nbsp;1、加汽油。 
&nbsp;&nbsp;&nbsp;&nbsp;2、里程表归零。 
&nbsp;&nbsp;&nbsp;&nbsp;3、清除警报信息。 
&nbsp;&nbsp;&nbsp;&nbsp;4、设定出发位置。 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;function Car($gas,&$position) 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->gas= $gas; //加汽油 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->meter = 0; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->warning =''; //清除警报信息 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->position = $position; //设定出发位置 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;function getWarning() //返回警报信息 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this->warning; 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;function getGas() //返回汽油表指数 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this->gas; 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 

&nbsp;&nbsp;&nbsp;&nbsp;function &getPosition() 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this->position; //返回当前小车的位置 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 

&nbsp;&nbsp;&nbsp;&nbsp;function setHeading($direction='e') 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 

&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 开动小汽车 
&nbsp;&nbsp;&nbsp;&nbsp;*@access public 
&nbsp;&nbsp;&nbsp;&nbsp;*@param INT 公里数 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;function run($km) 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp; 
&#125;
?> 
</textarea><br/><br/>这时候最关键的两个方法 setHeading 和 run 就变得简单了，由于小车装备了 Position 对象 $this->position， 所以关于坐标定位的事情它也不用管了， 交给 Position 对象好了， 他自己只要管理好自己的油表，里程表就可以了。完成以后的 Car 类变成这个样子了：<br/><br/><textarea name="code" class="php" rows="15" cols="100"><?php
class Car 
&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 小车的汽油量 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var 
&nbsp;&nbsp;&nbsp;&nbsp;*@access 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $gas; 

&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 里程记录 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var 
&nbsp;&nbsp;&nbsp;&nbsp;*@access 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $meter; 

&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 车的位置（由GPS自动控制） 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var Object position 
&nbsp;&nbsp;&nbsp;&nbsp;*@access private 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $position; 
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 发动机每1公里耗油量，这个车是0.1升 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var Integer 
&nbsp;&nbsp;&nbsp;&nbsp;*@access private 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $engine=0.1; 

&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 警报信息 
&nbsp;&nbsp;&nbsp;&nbsp;* 
&nbsp;&nbsp;&nbsp;&nbsp;*@var 
&nbsp;&nbsp;&nbsp;&nbsp;*@access 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;var $warning; 
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;小车的初始化。新车出场当然要 
&nbsp;&nbsp;&nbsp;&nbsp;1、加满汽油。 
&nbsp;&nbsp;&nbsp;&nbsp;2、里程表归零。 
&nbsp;&nbsp;&nbsp;&nbsp;3、清除警报信息。 
&nbsp;&nbsp;&nbsp;&nbsp;4、设定出发位置。 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp;function Car($gas,&$position) 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->gas= $gas; //加满汽油 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->meter = 0; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->warning =''; //清除警报信息 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->position = $position; //设定初始位置 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 

&nbsp;&nbsp;&nbsp;&nbsp;function getWarning() //返回警报信息 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this->warning; 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;function getGas() //返回汽油表指数 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this->gas; 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 

&nbsp;&nbsp;&nbsp;&nbsp;function &getPosition() 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this->position; //返回当前小车的位置 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 

&nbsp;&nbsp;&nbsp;&nbsp;function setHeading($direction='e') 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->position->setDirection($direction); //因为使用了Position 对象,小汽车不需要自己来操心XY坐标值了，交给Position 对象吧。 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 

&nbsp;&nbsp;&nbsp;&nbsp;/** 
&nbsp;&nbsp;&nbsp;&nbsp;* 开动小汽车 
&nbsp;&nbsp;&nbsp;&nbsp;*@access public 
&nbsp;&nbsp;&nbsp;&nbsp;*@param INT 公里数 
&nbsp;&nbsp;&nbsp;&nbsp;*/ 
&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;function run($km) 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$goodRunFlag = true;//是否成功完成任务。 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$maxDistance = $this->gas/$this->engine; //小车能够跑的最大距离。 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(($maxDistance)<$km) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->warning = '没有汽油了！';//设定警告信息，能跑多远就跑多远吧。 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$goodRunFlag = false;//但是任务肯定完成不了。 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$maxDistance=$km; //没有问题，完成任务以后就可以停下来休息了。 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->position->move($maxDistance);//在坐标上移动由Position对象来完成，小汽车只要负责自己的油耗和公里表就可以了。 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->gas -= $maxDistance*$this->engine;//消耗汽油 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->meter += $maxDistance; //增加公里表计数 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $goodRunFlag; 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&#125;
?> </textarea><br/><br/>讲到这里我想我的这篇文章也该结束了。别着急，我当然还记得 Position 类还没有完成，但是有了上面小汽车的例子 Position 应该就非常简单了， 如果你理解了这个小汽车的类， 现在就是你一展身手的时候了， 你来完成这个Position 对象吧， 我相信你能够完成它（其实这正是面向对象和封装的美妙之处）。你需要记住先从Position 的方法开始设计比如：<br/> <br/><br/>getX() <br/>getY() <br/>move() <br/>setDirection() <br/>所谓类就是指某一类的事物，它可以是具体的（Car）也可以是抽象的（Position），我们通过封装简化了使用和操作就像我们使用电视，手机一样一点都不复杂。<br/><br/>一篇好的入门教程应该<br/><br/>生动真实的例子。 <br/>不但提供了正确的概念，在变量和函数命名，函数封装和调用上也值的学习。 <br/>即便你熟悉了面向对象编程以后也不会认为当初的例子有什么不妥之处。 <br/>如果你读完教程动手的话一定能够深刻体会到教程的美妙之处，大大减少了走弯路的机会。 <br/>好的代码是可以被人像书一样读懂，你认为呢？ <br/>
]]>
</description>
</item><item>
<link>http://www.206c.net/blog/post/58/</link>
<title><![CDATA[优化PHP执行效率的40条技巧]]></title> 
<author>零度溫柔 &lt;nickdraw@qq.com&gt;</author>
<category><![CDATA[PHP资源]]></category>
<pubDate>Fri, 10 Jul 2009 17:01:15 +0000</pubDate> 
<guid>http://www.206c.net/blog/post/58/</guid> 
<description>
<![CDATA[ 
	1.如果一个方法能被静态，那就声明他为静态的，速度可提高1/4;<br/><br/>2.echo的效率高于print,因为echo没有返回值，print返回一个整型;<br/><br/>3.在循环之前设置循环的最大次数，而非在在循环中;<br/><br/>4.销毁变量去释放内存，特别是大的数组;<br/><br/>5.避免使用像__get, __set, __autoload等魔术方法;<br/><br/>6.requiere_once()比较耗资源;<br/><br/>7.在includes和requires中使用绝对路径，这样在分析路径花的时间更少;<br/><br/>8.如果你需要得sexinsex到脚本执行时的时间，$_SERVER['REQUSET_TIME']优于time();<br/><br/>9.能使用字符处理函数的，尽量用他们，因为效率高于正则;<br/><br/>10.str_replace字符替换比正则替换preg_replace快，但strtr比str_replace又快1/4;<br/><br/>11.如果一个函数既能接受数组又能接受简单字符做为参数，例如字符替换，并且参数列表不是太长，可以考虑多用一些简洁的替换语句，一次只替换一个字符，而不是接受数组做为查找和替换参数。大事化小，1+1>2;<br/><br/>12.用@掩盖错误会降低脚本运行速度;<br/><br/>13.$row['id']比$row[id]速度快7倍，建议养成数组键加引号的习惯;<br/><br/>14.错误信息很有用;<br/><br/>15.在循环里别用函数，例如For($x=0; $x < count($array); $x), count()函数在外面先计算;<br/><br/>16.在方法里建立局部变量速度最快，97xxoo几乎和在方法里调用局部变量一样快;<br/><br/>17.建立一个全局变量要比局部变量要慢2倍;<br/><br/>18.建立一个对象属性(类里面的变量)例如($this->prop++)比局部变量要慢3倍;<br/><br/>19.建立一个未声明的局部变量要比一个初始化的局部变量慢9-10倍;<br/><br/>20.声明一个未被任何一个函数使用过的全局变量也会使性能降低(和声明相同数量的局部变量一样)，PHP可能去检查这个全局变量是否存在;<br/><br/>21.方法的性能和在一个类里面定义的方法的数目没有关系，因为我添加10个或多个方法到测试的类里面(这些方法在测试方法的前后)后性能没什么差异;<br/><br/>22.在子类里方法的性能优于在基类中;<br/><br/>23.只调用一个参数并且函数体为空的函数运行花费的时间等于7-8次$localvar++运算，而一个类似的方法(类里的函数)运行等于大约15次$localvar++运算;<br/><br/>24.Surrounding your string by ‘ instead of ” will make things interpret a little faster since php looks for variables inside “…” but not inside ‘…’. Of course you can only do this when you don’t need to have variables in the string.<br/><br/>25.当输出字符串时用逗号代替点分割更快些。注意：这只对echo起作用，这个函数能接受一些字符串作为参数;<br/><br/>26.在apache服务器里一个php脚本页面比相应的HTML静态页面生成至少要多花2-10倍的时间，建议多用些静态HTML页面和少量的脚步;<br/><br/>27.除非你的安装了缓存，不然你的php脚本每次被访问都需要被重编译。建议安装个php缓存程序，这样通过去除一些重复的编译来很明显的提高你20-100%的性能;<br/><br/>28.建议用memcached，高性能的分布式内存对象缓存系统，提高动态网络应用程序性能，减轻数据库的负担;<br/><br/>29.使用ip2long()和long2ip()函数把IP地址转成整型存放进数据库而非字符型。这几乎能降低1/4的存储空间。同时可以很容易对地址进行排序和快速查找;<br/><br/>30.使用checkdnsrr()通过域名存在性来确认部分email地址的有效性，这个内置函数能保证每一个的域名对应一个IP地址;<br/><br/>31.如果你在使用php5和mysql4.1以上的版本，考虑使用mysql_*的改良函数mysqli_*;<br/><br/>32.试着喜欢使用三元运算符(?：);<br/><br/>33.在你想在彻底重做你的项目前，看看PEAR有没有你需要的。PEAR是个巨大的资源库，很多php开发者都知道;<br/><br/>34.使用highlight_file()能自动打印一份很好格式化的页面源代码的副本;<br/><br/>35.使用error_reporting(0)函数来预防潜在的敏感信息显示给用户。理想的错误报告应该被完全禁用在php.ini文件里。可是如果你在用一个共享的虚拟主机，php.ini你不能修改，那么你最好添加error_reporting(0)函数，放在每个脚本文件的第一行(或用require_once()来加载)这能有效的保护敏感的SQL查询和路径在出错时不被显示;<br/><br/>36.使用 gzcompress() 和gzuncompress()对容量大的字符串进行压缩(解压)在存进(取出)数据库时。这种内置的函数使用gzip算法能压缩到90%;<br/><br/>37.通过参数变量地址得引用来使一个函数有多个返回值。你可以在变量前加个“&”来表示按地址传递而非按值传递;<br/><br/>38.Fully understand “magic quotes” and the dangers of SQL injection. I’m hoping that most developers reading this are already familiar with SQL injection. However, I list it here because it’s absolutely critical to understand. If you’ve never heard the term before, spend the entire rest of the day googling and reading.<br/><br/>39.使用strlen()因为要调用一些其他操作例如lowercase和hash表查询所以速度不是太好，我们可以用isset()来实现相似的功能，isset()速度优于strlen();<br/><br/>40.When incrementing or decrementing the value of the variable $i++ happens to be a tad slower then ++$i. This is something PHP specific and does not apply to other languages, so don’t go modifying your C or Java code thinking it’ll suddenly become faster, it won’t. ++$i happens to be faster in PHP because instead of 4 opcodes used for $i++ you only need 3. Post incrementation actually causes in the creation of a temporary var that is then incremented. While pre-incrementation increases the original value directly. This is one of the optimization that opcode optimized like Zend’s PHP optimizer. It is a still a good idea to keep in mind since not all opcode optimizers perform this optimization and there are plenty of ISPs and servers running without an opcode optimizer.<br/>
]]>
</description>
</item><item>
<link>http://www.206c.net/blog/post/54/</link>
<title><![CDATA[6.18 mysql 数据增删查改。php + flex 3]]></title> 
<author>零度溫柔 &lt;nickdraw@qq.com&gt;</author>
<category><![CDATA[PHP资源]]></category>
<pubDate>Mon, 08 Jun 2009 15:02:46 +0000</pubDate> 
<guid>http://www.206c.net/blog/post/54/</guid> 
<description>
<![CDATA[ 
	<textarea name="code" class="sql" rows="15" cols="100">
CREATE TABLE IF NOT EXISTS `myuser` (
&nbsp;&nbsp;`id` int(11) NOT NULL auto_increment,
&nbsp;&nbsp;`username` varchar(200) NOT NULL,
&nbsp;&nbsp;`password` varchar(20) NOT NULL,
&nbsp;&nbsp;`age` int(2) NOT NULL,
&nbsp;&nbsp;PRIMARY KEY&nbsp;&nbsp;(`id`)
) ENGINE=MyISAM&nbsp;&nbsp;DEFAULT CHARSET=gbk AUTO_INCREMENT=16 ;

INSERT INTO `myuser` (`id`, `username`, `password`, `age`) VALUES
(1, '张三', '123', 23),
(2, '李四', '222', 18),
(3, '周小东', '333', 45),
(4, '皮皮鲁', '2246', 18),
(5, '鲁西西', '3389', 25),
(6, '张龙', '444', 35),
(7, '李奔', '5656', 56),
(8, '赵晓川', '566', 46),
(9, '令狐冲', '778', 27),
(10, '韦小宝', '3434', 19),
(11, '乔峰', '988', 28),
(12, '周正龙', '333', 16),
(13, '赵园', '648915', 0),
(14, '黄洛怡', '65416', 0),
(15, '薛军锋', '2sdfe', 0);
</textarea><br/><br/><textarea name="code" class="JS" rows="15" cols="100">
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.controls.dataGridClasses.DataGridItemRenderer;
import mx.events.CloseEvent;
import mx.events.DataGridEvent;
import mx.rpc.events.ResultEvent;
import mx.managers.CursorManager;
import mx.utils.ObjectUtil;

import mx.rpc.http.HTTPService;
import mx.rpc.events.FaultEvent;
import mx.rpc.AsyncToken;

//include the constant definition of the server endpoint URL
include "myuserconfig.as";

/**
 * gateway : this is the communication layer with the server side php code
 */
private var gateway:HTTPService = new HTTPService();

/**
 * the array collection holds the rows that we use in the grid
 */
[Bindable]
public var dataArr:ArrayCollection = new ArrayCollection();

/**
 * column that we order by. This is updated each time the users clicks on the 
 * grid column header. 
 * see headerRelease="setOrder(event);" in the DataGrid instantiation in the 
 * mxml file
 */
private var orderColumn:Number;


/**
 * the list of fields in the database table
 * needed to parse the response into hashes
 */ 
private var fields:Object = &#123; 'id':Number, 'username':String, 'password':String, 'age':Number&#125;;

/**
 * Executes when the mxml is completed loaded. Initialize the Rest Gateway.
 */
private function initApp():void 
&#123;

&nbsp;&nbsp;&nbsp;&nbsp;/**
&nbsp;&nbsp;&nbsp;&nbsp; * initialize the gateway
&nbsp;&nbsp;&nbsp;&nbsp; * - this will take care off server communication and simple xml protocol.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;gateway.url = ENDPOINT_URL;
&nbsp;&nbsp;&nbsp;&nbsp;gateway.method = "POST";
&nbsp;&nbsp;&nbsp;&nbsp;gateway.useProxy = false;
&nbsp;&nbsp;&nbsp;&nbsp;gateway.resultFormat = "e4x";

&nbsp;&nbsp;&nbsp;&nbsp;/**
&nbsp;&nbsp;&nbsp;&nbsp; * set the event handler which prevents editing of the primary key
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;dataGrid.addEventListener(DataGridEvent.ITEM_EDIT_BEGINNING, editCellHandler);

&nbsp;&nbsp;&nbsp;&nbsp;/**
&nbsp;&nbsp;&nbsp;&nbsp; * set the event handler which triggers the update actions - everytime an 
&nbsp;&nbsp;&nbsp;&nbsp; * edit operation is finished
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;dataGrid.addEventListener(DataGridEvent.ITEM_EDIT_END, editCellEnd);

&nbsp;&nbsp;&nbsp;&nbsp;gateway.addEventListener(ResultEvent.RESULT, resultHandler);
&nbsp;&nbsp;&nbsp;&nbsp;gateway.addEventListener(FaultEvent.FAULT, faultHandler);
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;fill();
&#125;

/**
 * Disallow editing of the primary key column.
 * @param e DataGridEvent contains details about the row and column of the grid 
 * where the user clicked
 */
private function editCellHandler(e:DataGridEvent):void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;/**
&nbsp;&nbsp;&nbsp;&nbsp; * if the user clicked on the primary key column, stop editing
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;if(e.dataField == "idCol")
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.preventDefault();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&#125;

/**
 * Click handler for "Filter" button.
 * When setting another filter, refresh the collection, and load the new data
 */
private function filterResults():void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;fill();
&#125;

/**
 * Event handler triggered when the user finishes editing an entry
 * triggers an "update" server command
 */
private function editCellEnd(e:DataGridEvent):void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;var dsRowIndex:int = e.rowIndex;
&nbsp;&nbsp;&nbsp;&nbsp;var dsFieldName:String = e.dataField;
&nbsp;&nbsp;&nbsp;&nbsp;var dsColumnIndex:Number = e.columnIndex;

&nbsp;&nbsp;&nbsp;&nbsp;var vo:* = dataArr[dsRowIndex];
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;var col:DataGridColumn = dataGrid.columns[dsColumnIndex];
&nbsp;&nbsp;&nbsp;&nbsp;var newvalue:String = dataGrid.itemEditorInstance[col.editorDataField];

&nbsp;&nbsp;&nbsp;&nbsp;trace("a:" + dsRowIndex + ", " + dsFieldName + ", " + dsColumnIndex);

&nbsp;&nbsp;&nbsp;&nbsp;var parameters:* =
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"id": vo.idCol,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"username": vo.usernameCol,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"password": vo.passwordCol,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"age": vo.ageCol&nbsp;&nbsp;&nbsp;&nbsp;&#125;

&nbsp;&nbsp;parameters[dsFieldName.substr(0,dsFieldName.length-3)] = newvalue;

&nbsp;&nbsp;/**
&nbsp;&nbsp; * execute the server "update" command
&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;doRequest("Update", parameters, saveItemHandler);&nbsp;&nbsp;&nbsp;&nbsp;

&#125;

/**
 * result handler for the "update" server command.
 * Just alert the error, or do nothing if it's ok - the data has already 
 * been updated in the grid
 */
private function saveItemHandler(e:Object):void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;if (e.isError)
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Alert.show("Error: " + e.data.error);
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;&nbsp;&nbsp; 
&#125;

/**
 * dragHeader handler for the datagrid. This handler is executed when the user 
 * clicks on a header column in the datagrid
 * updates the global orderColumn variable, refreshes the TableCollection
 * @param event DataGridEvent details about the column
 */
private function setOrder(event:DataGridEvent):void 
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;orderColumn = event.columnIndex;
&nbsp;&nbsp;&nbsp;&nbsp;var col:DataGridColumn = dataGrid.columns[orderColumn];
&nbsp;&nbsp;&nbsp;&nbsp;col.sortDescending = !col.sortDescending;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;event.preventDefault();
&nbsp;&nbsp;&nbsp;&nbsp;fill();
&#125;

/**
 * Click handler for the "Save" button in the "Add" state
 * collects the information in the form and adds a new object to the collection
 */
private function insertItem():void &#123;
&nbsp;&nbsp;&nbsp;&nbsp;var parameters:* =
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"method": "Insert",&nbsp;&nbsp;&nbsp;&nbsp;"username": usernameCol.text,&nbsp;&nbsp;&nbsp;&nbsp;"password": passwordCol.text,&nbsp;&nbsp;&nbsp;&nbsp;"age": ageCol.text&nbsp;&nbsp;&nbsp;&nbsp;&#125;;

&nbsp;&nbsp;/**
&nbsp;&nbsp; * execute the server "insert" command
&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;doRequest("Insert", parameters, insertItemHandler);
&#125;

/**
 * Result handler for the insert call.
 * Alert the error if it exists
 * if the call went through ok, return to the list, and refresh the data
 */
private function insertItemHandler(e:Object):void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;if (e.isError)
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Alert.show("Error: " + e.data.error);
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goToView();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fill();
&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;&nbsp;&nbsp; 
&#125;

/** 
 * general utility function for refreshing the data 
 * gets the filtering and ordering, then dispatches a new server call
 *
 */
private function fill():void 
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;/**
&nbsp;&nbsp;&nbsp;&nbsp; * find the order parameters
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;var desc:Boolean = false;
&nbsp;&nbsp;&nbsp;&nbsp;var orderField:String = '';
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;if(!isNaN(orderColumn))
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var col:DataGridColumn = dataGrid.columns[orderColumn];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;desc = col.sortDescending;
&nbsp;&nbsp;&nbsp;&nbsp;//remove the 'Col' particle
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;orderField = col.dataField.substr(0,col.dataField.length-3);
&nbsp;&nbsp;&nbsp;&nbsp;&#125;

&nbsp;&nbsp;&nbsp;&nbsp;dataGrid.enabled = false;
&nbsp;&nbsp;&nbsp;&nbsp;CursorManager.setBusyCursor();

&nbsp;&nbsp;&nbsp;&nbsp;var parameters:* =
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"orderField": orderField,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"orderDirection": (desc) ? "DESC" : "ASC", 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"filter": filterTxt.text
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;/**
&nbsp;&nbsp; * execute the server "select" command
&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;doRequest("FindAll", parameters, fillHandler);
&#125;

/** 
 * result handler for the fill call. 
 * if it is an error, show it to the user, else refill the arraycollection with the new data
 *
 */
private function fillHandler(e:Object):void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;if (e.isError)
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Alert.show("Error: " + e.data.error);
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataArr.removeAll();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for each(var row:XML in e.data.row) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var temp:* = &#123;&#125;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (var key:String in fields) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp[key + 'Col'] = row[key];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataArr.addItem(temp);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CursorManager.removeBusyCursor();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataGrid.enabled = true;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;&nbsp;&nbsp;
&#125;

/**
 * Click handler for the "delete" button in the list
 * confirms the action and launches the deleteClickHandler function
 */
private function deleteItem():void &#123;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;if (dataGrid.selectedItem)
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Alert.show("您确定要删除本数据吗?",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Confirm Delete", 3, this, deleteClickHandler);
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;
&#125;

/**
 * Event handler function for the Confirm dialog raises when the 
 * Delete button is pressed.
 * If the pressed button was Yes, then the product is deleted.
 * @param object event
 * @return nothing
 */ 
private function deleteClickHandler(event:CloseEvent):void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;if (event.detail == Alert.YES) 
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var vo:* = dataGrid.selectedItem;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var parameters:* =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"id": vo.idCol
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;

&nbsp;&nbsp;&nbsp;&nbsp;/**
&nbsp;&nbsp;&nbsp;&nbsp; * execute the server "delete" command
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;doRequest("Delete", parameters, deleteHandler);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setTimeout( function():void
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataGrid.destroyItemEditor();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1);
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&#125;

public function deleteHandler(e:*):void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;if (e.isError)
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Alert.show("Error: " + e.data.error);
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var id:Number = parseInt(e.data.toString(), 10);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (var index:Number = 0; index < dataArr.length; index++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (dataArr[index].idCol == id)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataArr.removeItemAt(index);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;&nbsp;&nbsp; 
&#125;

/**
 * deserializes the xml response
 * handles error cases
 *
 * @param e ResultEvent the server response and details about the connection
 */
public function deserialize(obj:*, e:*):*
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;var toret:Object = &#123;&#125;;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;toret.originalEvent = e;

&nbsp;&nbsp;&nbsp;&nbsp;if (obj.data.elements("error").length() > 0)
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;toret.isError = true;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;toret.data = obj.data;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;toret.isError = false;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;toret.metadata = obj.metadata;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;toret.data = obj.data;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;

&nbsp;&nbsp;&nbsp;&nbsp;return toret;
&#125;

/**
 * result handler for the gateway
 * deserializes the result, and then calls the REAL event handler
 * (set when making a request in the doRequest function)
 *
 * @param e ResultEvent the server response and details about the connection
 */
public function resultHandler(e:ResultEvent):void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;var topass:* = deserialize(e.result, e);
&nbsp;&nbsp;&nbsp;&nbsp;e.token.handler.call(null, topass);
&#125;

/**
 * fault handler for this connection
 *
 * @param e FaultEvent the error object
 */
public function faultHandler(e:FaultEvent):void
&#123;
&nbsp;&nbsp;var errorMessage:String = "Connection error: " + e.fault.faultString; 
&nbsp;&nbsp;&nbsp;&nbsp;if (e.fault.faultDetail) 
&nbsp;&nbsp;&nbsp;&nbsp;&#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errorMessage += "&#92;n&#92;nAdditional detail: " + e.fault.faultDetail; 
&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp;Alert.show(errorMessage);
&#125;

/**
 * makes a request to the server using the gateway instance
 *
 * @param method_name String the method name used in the server dispathcer
 * @param parameters Object name value pairs for sending in post
 * @param callback Function function to be called when the call completes
 */
public function doRequest(method_name:String, parameters:Object, callback:Function):void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;// add the method to the parameters list
&nbsp;&nbsp;&nbsp;&nbsp;parameters['method'] = method_name;

&nbsp;&nbsp;&nbsp;&nbsp;gateway.request = parameters;

&nbsp;&nbsp;&nbsp;&nbsp;var call:AsyncToken = gateway.send();
&nbsp;&nbsp;&nbsp;&nbsp;call.request_params = gateway.request;

&nbsp;&nbsp;&nbsp;&nbsp;call.handler = callback;
&#125;


/**
 * Click handler when the user click the "Create" button
 * Load the "Update" canvas.
 */
public function goToUpdate():void
&#123;
&nbsp;&nbsp;applicationScreens.selectedChild = update;
&#125;

/**
 * Load the "View" canvas.
 */
public function goToView():void
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;applicationScreens.selectedChild = view;
&#125;
</textarea><br/><br/><textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" pageTitle="myuser" 
&nbsp;&nbsp;creationComplete="initApp()" backgroundGradientColors="[#ffffff, #ffffff]">
&nbsp;&nbsp;&nbsp;&nbsp;<mx:Script source="myuserScript.as" />
&nbsp;&nbsp;<mx:ViewStack id="applicationScreens" width="100%" height="100%">
&nbsp;&nbsp;&nbsp;&nbsp;<mx:Canvas id="view" width="100%" height="100%">
&nbsp;&nbsp;&nbsp;&nbsp;<mx:DataGrid id="dataGrid"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataProvider="&#123;dataArr&#125;"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rowCount="8"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;editable="true"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resizableColumns="true" 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;headerRelease="setOrder(event);"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;right="10" left="10" top="10" bottom="270" fontSize="12">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:columns>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:DataGridColumn headerText="ID" dataField="idCol" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:DataGridColumn headerText="姓名" dataField="usernameCol" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:DataGridColumn headerText="密码" dataField="passwordCol" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:DataGridColumn headerText="性别" dataField="ageCol" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</mx:columns>
&nbsp;&nbsp;&nbsp;&nbsp;</mx:DataGrid>
&nbsp;&nbsp;&nbsp;&nbsp;<mx:Button id="btnAddNew" click="goToUpdate()" icon="@Embed('icons/AddRecord.png')" toolTip="添加" x="10" bottom="240" fontSize="12" cornerRadius="2"/>
&nbsp;&nbsp;&nbsp;&nbsp;<mx:Button id="btnDelete" click="deleteItem()" icon="@Embed('icons/DeleteRecord.png')" toolTip="删除" x="58" bottom="240" cornerRadius="2"/>
&nbsp;&nbsp;&nbsp;&nbsp;<mx:Label text="按姓名查找" right="303" bottom="241" fontSize="12"/>
&nbsp;&nbsp;&nbsp;&nbsp;<mx:TextInput id="filterTxt" width="238" toolTip="按姓名查找" enter="filterResults()" right="58" bottom="241" fontSize="12" height="21"/>
&nbsp;&nbsp;&nbsp;&nbsp;<mx:Button click="filterResults()" id="filterButton" icon="@Embed('icons/SearchRecord.png')" toolTip="按姓名查找" right="10" bottom="241" cornerRadius="2"/>
&nbsp;&nbsp;</mx:Canvas>
&nbsp;&nbsp;<mx:Canvas id="update" width="100%" height="100%">
&nbsp;&nbsp;&nbsp;&nbsp;<mx:Panel width="282" height="224" layout="absolute" cornerRadius="0" title="添加数据" fontSize="12" horizontalCenter="-72" verticalCenter="-61" alpha="1.0" backgroundAlpha="1.0" borderStyle="solid" borderThickness="1" dropShadowEnabled="False" backgroundColor="#F5F5F5">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:Form id="myuserForm" borderStyle="solid" x="10" y="10" borderThickness="0">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:FormItem label="姓名" id="username_form" fontSize="12">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:TextInput id="usernameCol" text=""/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </mx:FormItem>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:FormItem label="密码" id="password_form" fontSize="12">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:TextInput id="passwordCol" text=""/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </mx:FormItem>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:FormItem label="性别" id="age_form" fontSize="12">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:TextInput id="ageCol" text=""/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </mx:FormItem>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</mx:Form>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:Button label="提交" id="btnSubmit" click="insertItem()"&nbsp;&nbsp;fontSize="12" cornerRadius="2"&nbsp;&nbsp;x="27" y="136"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:Button label="放弃返回" id="btnCancel" click="goToView()"&nbsp;&nbsp;fontSize="12" cornerRadius="2"&nbsp;&nbsp;x="93" y="136"/>
&nbsp;&nbsp;&nbsp;&nbsp;</mx:Panel>
&nbsp;&nbsp;</mx:Canvas>
&nbsp;&nbsp;</mx:ViewStack>
</mx:Application>
</textarea>
]]>
</description>
</item><item>
<link>http://www.206c.net/blog/post/51/</link>
<title><![CDATA[PHP + Flex 通信]]></title> 
<author>零度溫柔 &lt;nickdraw@qq.com&gt;</author>
<category><![CDATA[PHP资源]]></category>
<pubDate>Sat, 06 Jun 2009 18:02:12 +0000</pubDate> 
<guid>http://www.206c.net/blog/post/51/</guid> 
<description>
<![CDATA[ 
	PHP：<br/><textarea name="code" class="php" rows="15" cols="100">
<?php 
/* Thanks to Pete Mackie for the code below */ 

Define(’DATABASE_SERVER’, ’localhost’); 
Define(’DATABASE_USERNAME’, ’root’); 
Define(’DATABASE_PASSWORD’, ’root’); 
Define(’DATABASE_NAME’, ’flextest’); 

# Connect to the database 
$mysqli = new mysqli(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME); 

# Check connection 
if (mysqli_connect_errno()) &#123; 
&nbsp;&nbsp; printf("MySQL connect failed: %s&#92;n", mysqli_connect_error()); 
&nbsp;&nbsp; exit(); 
&#125; 

# Quote variable to make safe 
function quote_smart($value) &#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;global $mysqli; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Stripslashes 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (get_magic_quotes_gpc()) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$value = stripslashes($value); 

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Quote if not integer 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!is_numeric($value))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$value = $mysqli->real_escape_string($value); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $value; 
&#125; 

if (!empty($_POST) && $_SERVER[’REQUEST_METHOD’] == ’POST’) &#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($_POST[’emailaddress’] && $_POST[’username’]) &#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Add the user 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$query = sprintf("Insert INTO users VALUES (’’, ’%s’, ’%s’)", quote_smart($_POST[’username’]), quote_smart($_POST[’emailaddress’])); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!@$mysqli->query($query)) &#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("’flextest’ user database query insert error: %s&#92;n", $mysqli->error); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mysqli->close(); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&#125; 

# Return a list of all the users 
if (!$result=@$mysqli->query("Select * from users")) &#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("’flextest’ user database query select error: %s&#92;n", $mysqli->error); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mysqli->close(); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(); 
&#125; 

$xml_return = "<users>"; 
while ($user = mysqli_fetch_array($result, MYSQLI_ASSOC)) &#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$xml_return .= 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"<user><userid>".$user[’userid’]."</userid><username>".$user[’username’]."</username><emailaddress>".$user[’emailaddress’]."</emailaddress></user>&#92;n"; 
&#125; 
$xml_return.= "</users>"; 
$mysqli->close(); 
echo $xml_return; 
?>
</textarea><br/><br/>Flex:<br/><textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onInit()" xmlns="*" layout="absolute" backgroundGradientColors="[#ffffff, #c0c0c0]"> 
&nbsp;&nbsp; <mx:Script> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <![CDATA[ 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public function onInit():void 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#123; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; userRequest.send(); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]]> 
&nbsp;&nbsp; </mx:Script> 
&nbsp;&nbsp; <mx:HTTPService id="userRequest" url="request.php" useProxy="false" method="POST"> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:request xmlns=""> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <username>&#123;username.text&#125;</username><emailaddress>&#123;emailaddress.text&#125;</emailaddress> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</mx:request> 
&nbsp;&nbsp; </mx:HTTPService> 
&nbsp;&nbsp; <mx:Form x="22" y="10" width="356"> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:HBox> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:Label text="Username"/> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:TextInput id="username"/> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</mx:HBox> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:HBox> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:Label text="Email Address"/> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:TextInput id="emailaddress"/> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</mx:HBox> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:Button label="Submit" click="userRequest.send()"/> 
&nbsp;&nbsp; </mx:Form> 
&nbsp;&nbsp; <mx:DataGrid id="dgUserRequest" x="22" y="128" dataProvider="&#123;userRequest.lastResult.users.user&#125;"> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<mx:columns> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:DataGridColumn headerText="User ID" dataField="userid"/> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <mx:DataGridColumn headerText="User Name" dataField="username"/> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</mx:columns> 
&nbsp;&nbsp; </mx:DataGrid> 
&nbsp;&nbsp; <mx:TextInput x="22" y="292" id="selectedemailaddress" text="&#123;dgUserRequest.selectedItem.emailaddress&#125;"/> 
</mx:Application>
</textarea>
]]>
</description>
</item>
</channel>
</rss>