<?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>明泉 &#187; PHP</title>
	<atom:link href="http://liumingquan.net/html/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://liumingquan.net</link>
	<description>开尽春花芳草涧 遍通秋水月明泉</description>
	<lastBuildDate>Mon, 07 May 2012 02:59:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>为什么 Java 程序员常常瞧不起 PHP 程序员</title>
		<link>http://liumingquan.net/html/2012_02/why-java-programmers-look-down-on-php-programmer.html</link>
		<comments>http://liumingquan.net/html/2012_02/why-java-programmers-look-down-on-php-programmer.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 02:30:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[程序员]]></category>

		<guid isPermaLink="false">http://liumingquan.net/?p=641</guid>
		<description><![CDATA[这也是知乎中的一个问题，提问者的原文是：在工作中，为什么 Java 程序员常常瞧不起 PHP 程序员？我给提问者做了这样的回答：我的从业经历中碰到这种情况。相对于Java来说，PHP有着简单易学上手快的特点。所以，有些情况下是刚刚参加工作的年轻人，很快的掌握了PHP并应用于工作中，而工作多年的老职员，是用Java来开发。这就相当于老手瞧不起新手。 用数学举个例子，小朋友先学会从1数到10，然后知道了加减和乘除，知道了平方和开方，知道了一元一次，二元一次，二元二次方程组，然后学了高等数学，再往后是数学领域更复杂的只是了。一个学过高等数学(Java)的人，看不起一个刚刚学了开方平方(PHP)的人，这种情况还是满常见的。]]></description>
			<content:encoded><![CDATA[<p>这也是知乎中的一个问题，提问者的原文是：在工作中，为什么 Java 程序员常常瞧不起 PHP 程序员？我给提问者做了这样的回答：我的从业经历中碰到这种情况。相对于Java来说，PHP有着简单易学上手快的特点。所以，有些情况下是刚刚参加工作的年轻人，很快的掌握了PHP并应用于工作中，而工作多年的老职员，是用Java来开发。这就相当于老手瞧不起新手。<span id="more-641"></span></p>
<p>用数学举个例子，小朋友先学会从1数到10，然后知道了加减和乘除，知道了平方和开方，知道了一元一次，二元一次，二元二次方程组，然后学了高等数学，再往后是数学领域更复杂的只是了。一个学过高等数学(Java)的人，看不起一个刚刚学了开方平方(PHP)的人，这种情况还是满常见的。</p>
]]></content:encoded>
			<wfw:commentRss>http://liumingquan.net/html/2012_02/why-java-programmers-look-down-on-php-programmer.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何用php实现一个账号不能多个用户同时登录</title>
		<link>http://liumingquan.net/html/2012_02/php-user-login-not-meanwhile.html</link>
		<comments>http://liumingquan.net/html/2012_02/php-user-login-not-meanwhile.html#comments</comments>
		<pubDate>Tue, 21 Feb 2012 13:52:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[帐号]]></category>
		<category><![CDATA[登录]]></category>

		<guid isPermaLink="false">http://liumingquan.net/?p=636</guid>
		<description><![CDATA[这是知乎当中的一个问题，也是我注册了知乎之后，第一个回答的问题。提问者还提到，“要求：当某个账号登陆后，其它用户再登录该账号时，提示该账号已登陆。 因用户数量庞大，如何能高效实现？方法能详细具体点为好修改” 我给楼主做出了这样的答复：一个帐号成功登录之后，至少要做两件事情：1是在服务器端生成并保存session，2是在相关表中把用户登录状态从否改为是（例如user表中isonline从0改为1）。 按照楼主的想法，在做这两件事情之前，还应该做一件事情，是判断user表中isonline的值是0还是1，如果是0，则这是一个当前未登录系统的用户，这时开始做上边提到的两件事。如果是1，则是已经登录的用户，这时可以给出提示信息。 这个问题牵扯到了退出。如果用户正常点击退出按钮，则还是至少做两件事情：1是注销服务器端session，2是把相关表中的用户登录状态从是改为否(例如user表中isonline从1改为0)。 为了处理用户没有正常退出的情况，比如长时间无任何操作，或者直接关闭浏览器。也可以认为用户已经退出系统。长时间无任何操作，有时效性的session会自动注销(默认时间是似乎是20分钟)；直接关闭浏览器，session也是自动注销。可以有一个定时执行的程序，来检查已经登录的用户的session是否不存在，如果不存在，则把user表中isonline从1改为0。 以上基本能解决楼主程序上的要求。 至于效率，PHP代码的效率，数据库的效率，带宽充裕，服务器稳定，负载均衡器&#8230;&#8230; 网站建设的各个方面有各自提高效率的方法。话题比较大，我回答不了，等待高人解答。]]></description>
			<content:encoded><![CDATA[<p>这是知乎当中的一个问题，也是我注册了知乎之后，第一个回答的问题。提问者还提到，“要求：当某个账号登陆后，其它用户再登录该账号时，提示该账号已登陆。  因用户数量庞大，如何能高效实现？方法能详细具体点为好修改”<span id="more-636"></span></p>
<p>我给楼主做出了这样的答复：一个帐号成功登录之后，至少要做两件事情：1是在服务器端生成并保存session，2是在相关表中把用户登录状态从否改为是（例如user表中isonline从0改为1）。</p>
<p>按照楼主的想法，在做这两件事情之前，还应该做一件事情，是判断user表中isonline的值是0还是1，如果是0，则这是一个当前未登录系统的用户，这时开始做上边提到的两件事。如果是1，则是已经登录的用户，这时可以给出提示信息。</p>
<p>这个问题牵扯到了退出。如果用户正常点击退出按钮，则还是至少做两件事情：1是注销服务器端session，2是把相关表中的用户登录状态从是改为否(例如user表中isonline从1改为0)。</p>
<p>为了处理用户没有正常退出的情况，比如长时间无任何操作，或者直接关闭浏览器。也可以认为用户已经退出系统。长时间无任何操作，有时效性的session会自动注销(默认时间是似乎是20分钟)；直接关闭浏览器，session也是自动注销。可以有一个定时执行的程序，来检查已经登录的用户的session是否不存在，如果不存在，则把user表中isonline从1改为0。</p>
<p>以上基本能解决楼主程序上的要求。</p>
<p>至于效率，PHP代码的效率，数据库的效率，带宽充裕，服务器稳定，负载均衡器&#8230;&#8230; 网站建设的各个方面有各自提高效率的方法。话题比较大，我回答不了，等待高人解答。</p>
]]></content:encoded>
			<wfw:commentRss>http://liumingquan.net/html/2012_02/php-user-login-not-meanwhile.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP的8种数据类型</title>
		<link>http://liumingquan.net/html/2011_09/8-kinds-of-data-types-php.html</link>
		<comments>http://liumingquan.net/html/2011_09/8-kinds-of-data-types-php.html#comments</comments>
		<pubDate>Wed, 31 Aug 2011 23:18:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[数据类型]]></category>

		<guid isPermaLink="false">http://liumingquan.net/?p=545</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?PHP</span>
<span style="color: #666666; font-style: italic;">/*
	四种标量：字符串、整型、浮点、布尔；
	两种复合类型：对象、数组；
	两种特殊类型：资源、NULL；
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//字符串</span>
<span style="color: #000088;">$a</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;spple&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>	<span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//整型</span>
<span style="color: #000088;">$b</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">125</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>	<span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//浮点</span>
<span style="color: #000088;">$c</span><span style="color: #339933;">=</span><span style="color:#800080;">125.0</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>	<span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//布尔</span>
<span style="color: #000088;">$d</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$e</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>	<span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>	<span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//对象</span>
<span style="color: #000000; font-weight: bold;">class</span> F
<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$f</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> F<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$f</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>	<span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//数组</span>
<span style="color: #000088;">$g</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$g</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>	<span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//资源</span>
<span style="color: #000088;">$h</span><span style="color: #339933;">=</span><span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.google.com.hk/intl/zh-CN/images/logo_cn.png&quot;</span><span style="color: #339933;">,</span>r<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>	<span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//NULL</span>
<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span>	<span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://liumingquan.net/html/2011_09/8-kinds-of-data-types-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex和PHP通信</title>
		<link>http://liumingquan.net/html/2009_11/flex-and-php-communication.html</link>
		<comments>http://liumingquan.net/html/2009_11/flex-and-php-communication.html#comments</comments>
		<pubDate>Fri, 06 Nov 2009 05:05:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[软件]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[通信]]></category>

		<guid isPermaLink="false">http://liumingquan.net/?p=221</guid>
		<description><![CDATA[Flex很强大，但如果想让Flex操作数据库的话必须要通过其他的脚本语言，可以是PHP或者asp.net。我尝试用Flex和PHP通信，测试成功。开始的时候是从网上搜其他人的经验，但放在自己这里总是无法调试通过，出现各式各样，莫名其妙的错误。然后参考Flex官方文档和实例。在Flex的手册中，搜索“HTTPService”，有这样的描述：在 MXML 文件中使用 &#60;mx:HTTPService&#62; 标签代表 HTTPService 对象。当调用 HTTPService 对象的 send() 方法时，将发出对指定 URL 的 HTTP 请求，并且返回 HTTP 响应。可以选择向指定 URL 传递参数。如果没有使用基于服务器的代理服务，则只能使用 HTTP GET 或 POST 方法。如果将 useProxy 属性设置为 true 并使用基于服务器的代理服务，则还可以使用 HTTP HEAD、OPTIONS、TRACE 和 DELETE 方法。 看过手册中HTTPService的属性和方法，又读了官方的实例源码，我写了Flex和PHP通信的例子。程序是从Flex向PHP提交一个数字，PHP先判断一下是否是数字，如果是的话，把这个数字乘以10之后返回；如果不是则返回中文提示信息“不是数字”。 演示点击：Flex和PHP通信 源码如下： Demo.mxml的源代码： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [...]]]></description>
			<content:encoded><![CDATA[<p>Flex很强大，但如果想让Flex操作数据库的话必须要通过其他的脚本语言，可以是PHP或者asp.net。我尝试用Flex和PHP通信，测试成功。开始的时候是从网上搜其他人的经验，但放在自己这里总是无法调试通过，出现各式各样，莫名其妙的错误。然后参考Flex官方文档和实例。在Flex的手册中，搜索“HTTPService”，有这样的描述：在 MXML 文件中使用 &#60;mx:HTTPService&#62; 标签代表 HTTPService 对象。当调用 HTTPService 对象的 send() 方法时，将发出对指定 URL 的 HTTP 请求，并且返回 HTTP 响应。可以选择向指定 URL 传递参数。如果没有使用基于服务器的代理服务，则只能使用 HTTP GET 或 POST 方法。如果将 useProxy 属性设置为 true 并使用基于服务器的代理服务，则还可以使用 HTTP HEAD、OPTIONS、TRACE 和 DELETE 方法。<span id="more-221"></span></p>
<p>看过手册中HTTPService的属性和方法，又读了官方的实例源码，我写了Flex和PHP通信的例子。程序是从Flex向PHP提交一个数字，PHP先判断一下是否是数字，如果是的话，把这个数字乘以10之后返回；如果不是则返回中文提示信息“不是数字”。</p>
<p>演示点击：<a href="http://liumingquan.net/Uploads/Flex/PHP/Demo1/Demo.html" target="_blank">Flex和PHP通信</a></p>
<p>源码如下：</p>
<p>Demo.mxml的源代码：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">&lt;?</span>xml version<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;1.0&quot;</span> encoding<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;</span>mx<span style="color: #339933;">:</span>Application xmlns<span style="color: #339933;">:</span>mx<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;absolute&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;</span>mx<span style="color: #339933;">:</span>Script<span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span>
			import mx.<span style="color: #202020;">rpc</span>.<span style="color: #202020;">events</span>.<span style="color: #202020;">ResultEvent</span><span style="color: #339933;">;</span>
			import mx.<span style="color: #202020;">rpc</span>.<span style="color: #202020;">events</span>.<span style="color: #202020;">FaultEvent</span><span style="color: #339933;">;</span>
			import mx.<span style="color: #202020;">controls</span>.<span style="color: #202020;">Alert</span><span style="color: #339933;">;</span>
&nbsp;
	        public <span style="color: #000000; font-weight: bold;">function</span> handleXml<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>ResultEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #993333;">void</span>
            <span style="color: #009900;">&#123;</span>
				TextArea1.<span style="color: #202020;">text</span> <span style="color: #339933;">=</span> event.<span style="color: #202020;">result</span>.<span style="color: #202020;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				TextInput2.<span style="color: #202020;">text</span> <span style="color: #339933;">=</span> event.<span style="color: #202020;">result</span>.<span style="color: #202020;">option</span>.<span style="color: #202020;">ReturnData</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
	        public <span style="color: #000000; font-weight: bold;">function</span> handleFault<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>FaultEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #993333;">void</span>
	        <span style="color: #009900;">&#123;</span>
	           Alert.<span style="color: #202020;">show</span><span style="color: #009900;">&#40;</span>event.<span style="color: #202020;">fault</span>.<span style="color: #202020;">faultString</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>               
	        <span style="color: #009900;">&#125;</span> 
		<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;/</span>mx<span style="color: #339933;">:</span>Script<span style="color: #339933;">&gt;</span> 
&nbsp;
    <span style="color: #339933;">&lt;</span>mx<span style="color: #339933;">:</span>HTTPService id<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;xmlRpc&quot;</span> 
    	url<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;http://liumingquan.net/Uploads/Flex/PHP/Demo1/Demo.php&quot;</span>
       	result<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;handleXml(event)&quot;</span> 
    	fault<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;handleFault(event)&quot;</span> 
    	resultFormat<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;e4x&quot;</span><span style="color: #339933;">&gt;</span> 
	    <span style="color: #339933;">&lt;</span>mx<span style="color: #339933;">:</span>request<span style="color: #339933;">&gt;</span>
	        <span style="color: #339933;">&lt;</span>Data1<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#123;</span>TextInput1.<span style="color: #202020;">text</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>Data1<span style="color: #339933;">&gt;</span>
	    <span style="color: #339933;">&lt;/</span>mx<span style="color: #339933;">:</span>request<span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;/</span>mx<span style="color: #339933;">:</span>HTTPService<span style="color: #339933;">&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;</span>mx<span style="color: #339933;">:</span>TextInput x<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;10&quot;</span> y<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;10&quot;</span> id<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;TextInput1&quot;</span> <span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>mx<span style="color: #339933;">:</span>Button x<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;178&quot;</span> y<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;10&quot;</span> label<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;Button&quot;</span> id<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;Button1&quot;</span> click<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;xmlRpc.send()&quot;</span><span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>mx<span style="color: #339933;">:</span>TextInput x<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;10&quot;</span> y<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;40&quot;</span> id<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;TextInput2&quot;</span><span style="color: #339933;">/&gt;</span>
	<span style="color: #339933;">&lt;</span>mx<span style="color: #339933;">:</span>TextArea x<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;10&quot;</span> y<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;70&quot;</span> height<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;216&quot;</span> width<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;233&quot;</span> id<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;TextArea1&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>mx<span style="color: #339933;">:</span>Application<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>PHP的源码（Demo.php）如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #b1b100;">if</span>	<span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Data1&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$ReturnData</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Data1&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$ReturnData</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;不是数字&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$results</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;options&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$results</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;option&gt;&lt;ReturnData&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ReturnData</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/ReturnData&gt;&lt;/option&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$results</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;/options&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">print</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>如果碰到输入的字符不是数字，但在Flex中没有显示“不是数字”，而是显示乱码的情况，可以将Demo.php文件另存为UTF-8的格式即可看到正确的中文。在HTTPService中，还可以增加method的属性，值可以设置为POST或者GET，默认为GET。增加此属性后，PHP中的$_REQUEST["Data1"]就可以写成$_GET["Data1"]或者$_POST["Data1"]</p>
<p>Flex的开发环境是ADOBE FLEX BUILDER 3 build3.0.2.214193</p>
]]></content:encoded>
			<wfw:commentRss>http://liumingquan.net/html/2009_11/flex-and-php-communication.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

