<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="css/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>心动吧黑客BLOG</title><link>http://www.abcxd.com/abcxd/</link><description>心动吧官方网 您的选择</description><generator>RainbowSoft Studio Z-Blog 1.8 Spirit Build 80722</generator><language>zh-CN</language><copyright>Copyright ⊙ 2004-2009 心动吧 UrL:ABCXD.CoM All RiGhts Reserved</copyright><pubDate>Sat, 03 Jul 2010 17:30:48 +0800</pubDate><item><title>php搜索字符串使用与缺点(strpos)</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-strpos.html</link><pubDate>Sat, 05 Jun 2010 06:06:56 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-strpos.html</guid><description><![CDATA[<p><span style="color: #ff0000">明生注：由于在编写过程中发现strpos的一个挺大的缺点。。所以做一下笔录。。</span></p><p>&nbsp;&nbsp;&nbsp; 首先我们先看看strpos的作用在于对某一个字符串进行判断是否存在某一个单个或多个字符的函数..看事例</p><pre class="php" name="code">$strpos1 = &quot;这是母字符串&quot;; $strpos2 = &quot;母&quot;; if (strpos($str1,$str2)===false)//这里要注意第一个匹配 { //不存在 }else{ //能用ELSE就不用IF //存在 }</pre><p>上面的事例可以看出来。从&ldquo;这是母字符串&rdquo;中搜索是否存在&ldquo;母&rdquo;字。而此时因为在第三位出现。所以会返回真</p><p>但如果我们将要判断的字符串换成&ldquo;这&rdquo;那么此时因为有第1位出现。而php的判断则是为0。所以当我们判断&ldquo;这&rdquo;的字符串出现的时候会出现不存在的原因就在这里。</p><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-strpos.html" target="_blank">继续阅读《php搜索字符串使用与缺点(strpos)》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday.html">(D:)PHP程序漏洞</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=PHP">PHP</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=strpos">strpos</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E6%90%9C%E7%B4%A2%E5%AD%97%E7%AC%A6%E4%B8%B2">搜索字符串</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%88%A4%E6%96%AD%E6%9F%90%E4%B8%80%E4%B8%AA%E5%AD%97%E6%9F%90%E6%98%AF%E5%90%A6%E5%AD%98%E5%9C%A8">判断某一个字某是否存在</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-strpos.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-fopen-fclose-filesize.html" title="PHP学习笔记2-文件、数组、字符串">PHP学习笔记2-文件、数组、字符串</a>&nbsp;&nbsp;(2010-6-4 15:20:12)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/PHP-fread-fclose-fwrite-fgets.html" title="PHP中文件读写操作">PHP中文件读写操作</a>&nbsp;&nbsp;(2010-5-26 15:27:55)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/Bitrac-web.html" title="Bitrac个人博客系统后台权限越权和提升漏洞">Bitrac个人博客系统后台权限越权和提升漏洞</a>&nbsp;&nbsp;(2009-5-20 11:9:44)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-pear-mail.html" title="php pear mail包任意文件读写漏洞">php pear mail包任意文件读写漏洞</a>&nbsp;&nbsp;(2009-5-7 21:43:33)</p></ul>]]></description><category>(D:)PHP程序漏洞</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-strpos.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=313</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=313&amp;key=19a2a96c</trackback:ping></item><item><title>PHP学习笔记2-文件、数组、字符串</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/php/php-fopen-fclose-filesize.html</link><pubDate>Fri, 04 Jun 2010 15:20:12 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/php/php-fopen-fclose-filesize.html</guid><description><![CDATA[<p><span style="color: #ff0000">明生注：转一文件操作文章。挺好。。</span></p><div><strong>[</strong><strong>文件]</strong></div><div>&nbsp;</div><div><strong>站点路径</strong></div><div style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt">$DOCUMENT_ROOT = $_SERVER[&lsquo;DOCUMENT_ROOT&rsquo;]</div><div><strong>&nbsp;</strong></div><div><strong>打开/</strong><strong>关闭文件、文件信息等</strong></div><div>fopen() 打开文件 读、写、读写、追加等模式</div><div>fclose() 关闭文件</div><div>file_exist()</div><div>filesize()</div><div>unlink() 删除文件</div><div><strong>&nbsp;</strong></div><div><strong>写文件</strong></div><div>fwrite() = fputs() 写入一个字符串，可控制写入长度</div><div>file_put_contents() 不需要先调用fopen() 常用于从FTP或HTTP获取文件</div><div><strong>&nbsp;</strong></div><div><strong>读文件</strong></div><div><strong>行</strong></div><div>feof() 判断文件末尾</div><div>fgets() 读文件，可控制读入长度</div><div>fgetss() 可过滤字符，常用于读取别人所编写的文件（出于安全考虑）</div><div>fgetcsv() 一行数据中的用分隔符进行分割</div><div><strong>文件</strong></div><div>readfile() 无需fpoen()，打开文件输出到浏览器再关闭</div><div>fpassthru() 需要先调用fopen()</div><div>file() 返回行数据数组</div><div><strong>字符</strong></div><div>fgetc()</div><div>fread() 读取任意长度字节</div><div><strong>&nbsp;</strong></div><div><strong>文件定位</strong></div><div>rewind() 复位文件指针到开始</div><div>fseek() 指向文件某个位置</div><div>ftell() 返回指针字节位置</div><div><strong>&nbsp;</strong></div><div><strong>文件锁定</strong></div><div>flock() 文件加锁/解锁</div><div>LOCK_SH 读操作锁 共享</div><div>LOCK_EX 写操作锁 互斥</div><div>LOCK_UN 释放锁</div><div>LOCK_NB 防止在请求加锁时发生阻塞</div><div>非线程同步的</div><div><strong>&nbsp;</strong></div><div><strong>&nbsp;</strong></div><div><strong>[</strong><strong>数组]</strong></div><div><strong>&nbsp;</strong></div><div><strong>创建数组</strong></div><div>$test = array(&lsquo;first&rsquo;, &lsquo;second&rsquo;, &lsquo;third&rsquo;);</div><div>$test2 = range(1, 10) //1到10的数组</div><div>$test3 = range(1, 10, 2) //1到10的奇数数组</div><div>$test4 = range(10, 1, -1) //10到1的数组</div><div>$test5 = range(&lsquo;a&rsquo;, &lsquo;z&rsquo;) //字母a到z的字符数组</div><div><strong>&nbsp;</strong></div><div><strong>追加元素</strong></div><div>$test[3] = &lsquo;forth&rsquo;; //向数组test末尾添加新元素</div><div>array_push($test, &lsquo;forth&rsquo;)</div><div><strong>&nbsp;</strong></div><div><strong>foreach</strong><strong>循环</strong></div><div>foreach ($test as $ $current) {</div><div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $current.&rsquo; &lsquo;;</span></div><div>}</div><div><strong>&nbsp;</strong></div><div><strong>关键字</strong></div><div>$test = array( &lsquo;Tieres&rsquo; =&gt; 100, &lsquo;Oil&rsquo; =&gt; 10, &lsquo;Spark&rsquo; =&gt; 4);</div><div>foreach ($test as $key =&gt; $value) {</div><div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&hellip;&hellip;</div><div>}</div><div>while ($element = each($test)) {</div><div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $element[&lsquo;key&rsquo;].&rsquo;-&lsquo;.$element[&lsquo;value&rsquo;];</span></div><div>}</div><div>reset($test);</div><div>while( list($user, $psw) = each($test) )</div><div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo </span>&hellip;&hellip;</div><div><strong>&nbsp;</strong></div><div><strong>数组排序(</strong><strong>升/</strong><strong>降)</strong></div><div>一般排序：sort() rsort()</div><div>value排序：asort() arsort()</div><div>key排序：ksort() krsort()</div><div>用户定义排序：usort() uasort() uksort()</div><div>例：</div><div>usort ($test, &lsquo;compare&rsquo;);</div><div>function compare($x, $y) {</div><div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( $x[2] == $y[2] ) {</span></div><div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</span></div><div style="text-indent: 21pt">}</div><div style="text-indent: 21pt">else if ( $x[2] &lt; $y[2] ) {</div><div style="text-indent: 21pt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;</span></div><div style="text-indent: 21pt">}</div><div style="text-indent: 21pt">else {</div><div style="text-indent: 21pt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;</span></div><div style="text-indent: 21pt">}</div><div>}</div><div>反向排序：array_reverse() = rsort()</div><div>随机排序：array_rand() = shuffle()</div><div><strong>&nbsp;</strong></div><div><strong>内部指针</strong></div><div>reset() 指针移动到第一个元素</div><div>end() 指针移动到最后一个元素</div><div>each() 返回值-&gt;前移</div><div>next() 前移-&gt;返回值</div><div>prev() 与next()相反</div><div>current() 返回当前值</div><div>pos() 返回当前位置值</div><div><strong>&nbsp;</strong></div><div><strong>对数组中的每一个元素进行操作</strong></div><div>bool array_walk(array arr, string &lsquo;func&rsquo;, [mixed userdata]);</div><div>function func(value, key, userdata);</div><div><strong>&nbsp;</strong></div><div><strong>数组元素统计</strong></div><div>count() = sizeof()</div><div>array_count_values($array) 返回一个包含频率表的相关数组</div><div><strong>&nbsp;</strong></div><div><strong>将数组转化成标量变量(</strong><strong>可以为key</strong><strong>添加前缀等来解决冲突)</strong></div><div>$array = array( &lsquo;key1&rsquo; =&gt; &lsquo;value1&rsquo;, &lsquo;key2&rsquo; =&gt; &lsquo;value2&rsquo;, &lsquo;key3&rsquo; =&gt; &lsquo;value3&rsquo; );</div><div>extract($array);</div><div>echo &ldquo;$key1 $key2 $key3&rdquo;;</div><div>&nbsp;</div><div>&nbsp;</div><div><strong>[</strong><strong>字符串]</strong></div><div><strong>&nbsp;</strong></div><div><strong>过滤空格</strong></div><div>chop() = trim() 过滤除去空白字符及其他自定义字符</div><div>ltrim() rtrim()</div><div><strong>&nbsp;</strong></div><div><strong>格式化字符串</strong></div><div>nl2br() HTML格式化</div><div>printf()</div><div>sprintf()</div><div>大小写处理：Strtoupper() Strtolower() Ucfirst() Ucwords()</div><div>特殊字符引号、反斜杆、NULL字符处理：addslashes() stripslashes()</div><div>魔术引号</div><div><strong>&nbsp;</strong></div><div><strong>分割和重组</strong></div><div>explode()</div><div>implode() = join()</div><div>strtok()</div><div>例：</div><div>$token = strtok($test, &lsquo; &lsquo;);</div><div>echo $token.&rsquo;&lt;br /&gt;&rsquo;;</div><div>while($token != &lsquo;&rsquo;) {</div><div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $token = strtok(&lsquo; &lsquo;);</span></div><div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $token.&rsquo;&lt;br /&gt;&rsquo;;</span></div><div>}</div><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-fopen-fclose-filesize.html" target="_blank">继续阅读《PHP学习笔记2-文件、数组、字符串》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/php.html">(U:)传统学习PHP</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=PHP">PHP</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E6%96%87%E4%BB%B6">文件</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E6%95%B0%E7%BB%84">数组</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%AD%97%E7%AC%A6%E4%B8%B2">字符串</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-fopen-fclose-filesize.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-strpos.html" title="php搜索字符串使用与缺点(strpos)">php搜索字符串使用与缺点(strpos)</a>&nbsp;&nbsp;(2010-6-5 6:6:56)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/PHP-fread-fclose-fwrite-fgets.html" title="PHP中文件读写操作">PHP中文件读写操作</a>&nbsp;&nbsp;(2010-5-26 15:27:55)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html" title="PHP 数组array和foreach的应用(第六节)">PHP 数组array和foreach的应用(第六节)</a>&nbsp;&nbsp;(2010-3-29 4:22:37)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/Bitrac-web.html" title="Bitrac个人博客系统后台权限越权和提升漏洞">Bitrac个人博客系统后台权限越权和提升漏洞</a>&nbsp;&nbsp;(2009-5-20 11:9:44)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-pear-mail.html" title="php pear mail包任意文件读写漏洞">php pear mail包任意文件读写漏洞</a>&nbsp;&nbsp;(2009-5-7 21:43:33)</p></ul>]]></description><category>(U:)传统学习PHP</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/php/php-fopen-fclose-filesize.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=312</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=312&amp;key=da1e86d9</trackback:ping></item><item><title>PHP中文件读写操作</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/PHP-fread-fclose-fwrite-fgets.html</link><pubDate>Wed, 26 May 2010 15:27:55 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/PHP-fread-fclose-fwrite-fgets.html</guid><description><![CDATA[<p><span style="color: #ff0000">明生KISS注：此文章看着不错所以转来。方便查阅</span></p><p>刚开始学，有点涩，有点不太明白。就以记忆为主。在多加自己操作增加理解，直到有一天融会贯通 。</p><p>以下为文件读写操作的 基本PHP函数及模式（看不明白就记住他）</p><p>关于模式：</p><p>'r' - 只读方式打开， 文件指针置于文件头</p><p>'r+' - 读写方式打开，文件指针置于文件头</p><p>'w' - 只写打开，文件指针置于文件头， 文件被剪切为0字节， 如果文件不存在， 尝试建立文件</p><p>'w+' - 读写打开，文件指针置于文件头， 文件大小被剪切为0字节，如果文件不存在， 尝试建立文件</p><p>'a' - 只写方式打开，文件指针置于文件尾，如果文件不存在，尝试建立文件</p><p>'a+' - 读写打开，文件指针置于文件尾，如果文件不存在， 尝试建立文件<br />fgets &mdash;&nbsp; 从文件指针中读取一行<br />fgetss &mdash; 从文件指针中读取一行并过滤掉 HTML 标记<br />file &mdash; 把整个文件读入一个数组中<br />fgetcsv &mdash; 从文件指针中读入一行并解析 CSV 字段</p><p>&nbsp;</p><p>你一定用过&ldquo;网络硬盘&rdquo;吧，利用它可以按自己的需要新建文件夹来分门别类地把自己的一些文件保存起来，有的还可以在线编辑文件。</p><p>　　PHP中提供了一系列的I/O函数，能简捷地实现我们所需要的功能，包括文件系统操作和目录操作（如&ldquo;复制[copy]&rdquo;）。下面给大家介绍的是基本的文件读写操作：（１）读文件；（２）写文件；（３）追加到文件。</p><p><br />TEXT 代码:</p><p>作者： Mukul<br />翻译： 无伤 &lt;<a href="mailto:goghs@mail.com">goghs@mail.com</a>&gt;<br />&nbsp;</p><p>读取文件:</p><div class="codes"><pre class="php" style="width: 99%; height: 124px" name="code">&lt;?php $file_name=&quot;data.dat&quot;;// 要读取的文件的绝对路径: homedata.dat $file_pointer=fopen($file_name,&quot;r&quot;);// 打开文件，&quot;r&quot; 是一种模式，或者说我们要进行的操作方法，详见本文后面的介绍 $file_read=fread($file_pointer,filesize($file_name));// 通过文件指针读取文件内容 fclose($file_pointer);// 关闭文件 print&quot;读取到的文件内容是： $file_read&quot;;// 显示文件内容?&gt;</pre></div><p><br /><strong>写文件：</strong></p><p>&nbsp;</p><div class="codes"><pre class="php" name="code">&lt;?php $file_name=&quot;data.dat&quot;;// 绝对路径: homedata.dat $file_pointer=fopen($file_name,&quot;w&quot;);// &quot;w&quot;是一种模式，详见后面 fwrite($file_pointer,&quot;what you wanna write&quot;);// 先把文件剪切为0字节大小， 然后写入 fclose($file_pointer);// 结束 print&quot;数据成功写入文件&quot;; ?&gt;</pre><p><br /><strong>追加到文件后面：</strong></p><div class="codes"><pre class="php" name="code">&lt;?php $file_name=&quot;data.dat&quot;;// 绝对路径: homedata.dat $file_pointer=fopen($file_name,&quot;a&quot;);// &quot;w&quot;模式 fwrite($file_pointer,&quot;what you wanna append&quot;);// 不把文件剪切成0字节， 把数据追加到文件最后 fclose($file_pointer);// 结束 print&quot;数据成功追加到文件&quot;; ?&gt;</pre><br />以上只是简单介绍，下面我们要讨论一些更深层的。</div><div class="codes">有时候会发生多人写入的情况（最常见是在流量较大的网站），会产生无用的数据写入文件， 例如：</div><div class="codes">info.file文件内容如下 -&gt;</div><div class="codes">|1|Mukul|15|Male|India (n)<br />|2|Linus|31|Male|Finland (n)</div><div class="codes">现在两个人同时注册，引起文件破坏-&gt;</div><div class="codes">info.file -&gt;</div><div class="codes">|1|Mukul|15|Male|India<br />|2|Linus|31|Male|Finland<br />|3|Rob|27|Male|USA|<br />Bill|29|Male|USA</div><div class="codes">上例中当PHP写入Rob的信息到文件的时候，Bill正好也开始写入，这时候正好需要写入Rob纪录的'n'，引起文件破坏。</div><div class="codes">我们当然不希望发生这样的情况， 所以让我们看看文件锁定：</div><div class="codes">复制内容到剪贴板</div><div class="codes"><pre class="php" name="code">&lt;?php $file_name=&quot;data.dat&quot;; $file_pointer=fopen($file_name,&quot;r&quot;); $lock=flock($file_pointer, LOCK_SH);// 我使用4.0.2，所以用LOCK_SH，你可能需要直接写成 1. if($lock){ $file_read=fread($file_pointer,filesize($file_name));$lock=flock($file_pointer, LOCK_UN);// 如果版本小于PHP4.0.2， 用 3 代替 LOCK_UN } fclose($file_pointer); print&quot;文件内容为 $file_read&quot;; ?&gt;</pre><p><br />上例中，如果两个文件read.php和read2.php都要存取该文件，那么它们都可以读取，但是当一个程序需要写入的时候，它必须等待，直到读操作完成，文件所释放。</p><div class="codes"><pre class="php" name="code">&lt;?php $file_name=&quot;data.dat&quot;; $file_pointer=fopen($file_name,&quot;w&quot;); $lock=flock($file_pointer, LOCK_EX);// 如果版本低于PHP4.0.2， 用 2 代替 LOCK_EX if($lock){ fwrite($file_pointer,&quot;what u wanna write&quot;);flock($file_pointer, LOCK_UN);// 如果版本低于PHP4.0.2， 用 3 代替 LOCK_UN } fclose($file_pointer); print&quot;数据成功写入文件&quot;; ?&gt;</pre><p><br />虽然&quot;w&quot;模式用来覆盖文件， 单我觉得不适用。</p><div class="codes"><pre class="php" name="code">&lt;?php $file_name=&quot;data.dat&quot;; $file_pointer=fopen($file_name,&quot;a&quot;); $lock=flock($file_pointer, LOCK_EX);// 如果版本低于PHP4.0.2， 用 2 代替 LOCK_EX if($lock){ fseek($file_pointer,0, SEEK_END);// 如果版本小于PHP4.0RC1， 使用 fseek($file_pointer, filsize($file_name)); fwrite($file_pointer,&quot;what u wanna write&quot;);flock($file_pointer, LOCK_UN);// 如果版本低于PHP4.0.2， 用 3 代替 LOCK_UN } fclose($file_pointer); print&quot;数据成功写入文件&quot;; ?&gt;</pre><br />Hmmm...， 对于追加数据与其他操作有点不同，就是FSEEK! 确认文件指针在文件尾部总是一个好习惯。<br /><br />如果是在Windows系统下， 上面的文件中文件名前面需要加上''.<br />&nbsp;</div></div></div></div><p>&nbsp;</p><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/PHP-fread-fclose-fwrite-fgets.html" target="_blank">继续阅读《PHP中文件读写操作》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday.html">(D:)PHP程序漏洞</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=PHP">PHP</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=fgets">fgets</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=fgetss">fgetss</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=fopen">fopen</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=fread">fread</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=fclose">fclose</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=fwrite">fwrite</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E8%AF%BB%E5%8F%96%E6%96%87%E4%BB%B6">读取文件</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=php%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C">php文件操作</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/PHP-fread-fclose-fwrite-fgets.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-strpos.html" title="php搜索字符串使用与缺点(strpos)">php搜索字符串使用与缺点(strpos)</a>&nbsp;&nbsp;(2010-6-5 6:6:56)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-fopen-fclose-filesize.html" title="PHP学习笔记2-文件、数组、字符串">PHP学习笔记2-文件、数组、字符串</a>&nbsp;&nbsp;(2010-6-4 15:20:12)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/Bitrac-web.html" title="Bitrac个人博客系统后台权限越权和提升漏洞">Bitrac个人博客系统后台权限越权和提升漏洞</a>&nbsp;&nbsp;(2009-5-20 11:9:44)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/php-pear-mail.html" title="php pear mail包任意文件读写漏洞">php pear mail包任意文件读写漏洞</a>&nbsp;&nbsp;(2009-5-7 21:43:33)</p></ul>]]></description><category>(D:)PHP程序漏洞</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/PHPoday/PHP-fread-fclose-fwrite-fgets.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=307</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=307&amp;key=219b5904</trackback:ping></item><item><title>PHP 函数Finction与全局变量(第七节)</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html</link><pubDate>Tue, 30 Mar 2010 02:43:25 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html</guid><description><![CDATA[<p><span style="color: #ff0000">作者：心动吧明生KISS</span></p><p>我相信所有程序都会有函数的存在。。它的作用是帮助我们将行为或者动作给划分开来。以达到方便管理的作用。如果我们写一大片的程序。无认是读起来还是维护起来都是十分大的工程。如果将他分块而治。这就容易多了。现在我们来试试</p><p class="STYLE1">函数的使用</p><pre class="php" name="code">&lt;? <br/>　$a = 1; //A的值是1<br/>　$b = 2; //B的值是2<br/><br/>　$J = Jia($a,$b); //使用自定义的函数让他们相加<br/><br/>　echo $J;<br/><br/>　function Jia($stra,$strb)<br/>　{<br/>　　$c = $stra + $strb; //将传递进来的二个参数进行相加<br/>　　return $c; //并以return 返回结果给他们, <br/>　}<br/>?&gt;</pre><p>&nbsp;</p><p>运行后输出的结果： 3</p><p>明生注释：其实就是当Jia函数运行后。并加二者相加然后使用return返回值给他们...如果是一个过程。你可以直接使用echo输出就是了。而不用return..上面的这一种只是将变量进行一种复制镜像出来然后赋值给$stra而不是直接将$a的变量给他。。那现在我们来操作一下直接传入参数了..下面来试一下</p><p><span class="STYLE1"><strong><font color="#0000ff">函数传址的使用和写法</font></strong></span></p><div class="codes"><pre class="php" style="width: 98.19%; height: 231px" name="code">&lt;?<br/>　$a = 1; <br/>　vara($a); //直接代入函数去操作.这里注意哦。并没有给$a赋值你发现没有。平常都是这样$a = vara($a);。现在不是了..但是值一样变 <br/>　echo $a; //然后输出 <br/><br/>　function vara(&amp;$b) //在这里注意看。在变量的声明时多了一个 &amp; ，聪明的你应该看懂了吧。就是他了<br/>　{<br/>　　$b++; //让自身加1 <br/>　} <br/>?&gt; </pre></div><p>运行后输出的结果: 2</p><p>明生注释：在这一节特别要注意的是 <span class="STYLE1"><strong><font color="#0000ff">&amp;</font></strong></span> 他的作用就是让变量自身直接传址进来而不是传值。这二点需要注意哦。就是说你本来有一个变量A。他程序要取变量A值的时候只是将他复制一份镜像出来。然后再处理。如果你用到了 <span class="STYLE1"><strong><font color="#0000ff">&amp;</font></strong></span> 那么就是告诉PHP我需要将他的变量代入进来操作..懂了吗？不懂的话可以留言。现在我们再看看全局变量在程序块的使用。</p><p><span class="STYLE1"><strong><font color="#0000ff">全局变量如何在函数使用</font></strong></span></p><div class="codes"><pre class="php" name="code">&lt;?<br/>　$Var = 'Key'; <br/>　Bian(); //执行函数<br/><br/>　echo $Var; <br/><br/>　function Bian()<br/>　{<br/>　　global $Var; //这一步是最重要的。如果没有他就不知道$Var了。。注意大小写<br/>　　$Var = 'GO';<br/>　}<br/><br/>?&gt; </pre></div><p>运行后输出的结果： GO</p><p>明生注释：在上面这一点注意 global 的使用,他是将一个变量声明为全局变量的使用(注意：只能使用于自身的某个函数而不是所有函数)。不过这一节还有很多的内容在这里就不阵列出来了。如果哪位有兴趣继续研究下去。可以去看一下 php 手册当中的（变量范围）</p><p>&nbsp;</p><p align="center">就这样一天又过去了。还得继续努力学习。。加油</p><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html" target="_blank">继续阅读《PHP 函数Finction与全局变量(第七节)》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/php.html">(U:)传统学习PHP</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%AD%A6%E4%B9%A0php">学习php</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%87%BD%E6%95%B0">函数</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=function">function</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=return">return</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=php%E4%BC%A0%E5%9D%80">php传址</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=global">global</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html" title="PHP 数组array和foreach的应用(第六节)">PHP 数组array和foreach的应用(第六节)</a>&nbsp;&nbsp;(2010-3-29 4:22:37)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html" title="PHP 循环语句For_While_DoWhile(第五节)">PHP 循环语句For_While_DoWhile(第五节)</a>&nbsp;&nbsp;(2010-3-29 3:21:3)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html" title="PHP 判断语句switch(第四节)">PHP 判断语句switch(第四节)</a>&nbsp;&nbsp;(2010-3-29 3:11:22)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html" title="PHP 变量的补充(第三节)">PHP 变量的补充(第三节)</a>&nbsp;&nbsp;(2010-3-29 3:1:45)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-if-else.html" title="PHP 判断语句IF..else(第二节)">PHP 判断语句IF..else(第二节)</a>&nbsp;&nbsp;(2010-3-28 1:24:17)</p></ul>]]></description><category>(U:)传统学习PHP</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=306</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=306&amp;key=621c0d6a</trackback:ping></item><item><title>PHP 数组array和foreach的应用(第六节)</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html</link><pubDate>Mon, 29 Mar 2010 04:22:37 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html</guid><description><![CDATA[<p><span style="color: #ff0000">作者：心动吧明生KISS</span></p><p>数组很多编程里面都会有。而且时常用到，用来分类储存内容是最好的。因为他就像一个柜子。然后分成三层。而每一层里面又可以分划出来多个格来存放东西....现在我们就来学习一下什么是数组。。。 .</p><p class="STYLE3">数组的声明:<br/><pre class="php" name="code">&lt;?<br/>　$myarr = Array('aa','bb','cc'); //array是一个数组的声明。然后这个组里面有三个值。 <br/>　echo $myarr[1]; //然后我们取出第1个的值 也就是 bb<br/>?&gt;</pre></p><p>运行后输出的结果： bb</p><p>明生注释：这里面有一点需要知道的是。你有多少个值都可以写在里面。而且取的时候是以位数为标准的..也就是说如果第一位是aa那么你就需要使用 <span class="STYLE1"><strong><font color="#ff0000">数组变量[1]</font></strong></span> 这样取出来.以此类推.如果你想取某某的值。是不是非常的麻烦。不过聪明的php开发者早就想到了这一点。下面就让我们来看看是怎么个回事吧..</p><p class="STYLE3">数组的实名化: (不知道怎么叫好。哈哈所以随便给他一个名字。知道的朋友记得告诉我呀)<br/><pre class="php" name="code">&lt;?<br/>　$myarr = Array('A'=&gt;'aa' , 'B'=&gt;'bb' , 'C'=&gt;'cc'); //在这里 A 相当于 aa 的名字.取的时候直接用他的名字就行了<br/>　echo $myarr['C']; //然后我们取出以C为单位的值 也就是 cc 注意大小写 <br/>?&gt;</pre></p><p>运行后输出的结果： cc</p><p>明生注释：看到上面的代码是不是有点头晕呀。不用怕。现在我来给你们解答一下。。首先数组[1]的值是不是aa呢。但是如果以数字来标识。恐怕要找一个同学是挺难的。如果给他一个字符。那么我们要寻找某一个人是不是就简单多了呢？？你的想法是对的。。不过应该怎么写呢。首先，我们中国名字都是由左至右的。而他的碰巧也是。所以 姓 A 名 aa 也就顺理成章的用我们中国的姓氏来解释了.然后用 <span class="STYLE3"><strong><font color="#0000ff">=&gt;</font></strong></span> 方式告诉他..我A就能代表aa 。 但是如果我想全部读取这些值该怎么去做呢。。聪明的你应该会想到用循环吧。。那么用for？还是while? 其实这些都可以。只是不太方便的。现在来介绍一个更方便一些的循环吧。。专门针对数组的哦！！！</p><p class="STYLE3">闪亮登场的 foreach(){} 数组循环<br/><pre class="php" name="code">&lt;?<br/>　$myarr = Array('aa','bb','cc','dd'); //数组有四个元素<br/>　foreach( $myarr as $value ) //然后开始循环 每一次循环将抽取一个值并赋给 $value<br/>　{<br/>　　　echo &quot;$value&lt;br&gt;&quot;; <br/>　}<br/>?&gt; </pre></p><p>运行后输出的结果： <br /><br/>aa<br /><br/>bb<br /><br/>cc<br /><br/>dd<br /><br/>&nbsp;</p><p class="STYLE3">foreach(){} 数组循环之Key应用<br/><pre class="php" name="code">&lt;?<br/>　$myarr = Array('刘'=&gt; '德华' , '张'=&gt;'学友' , '郭'=&gt;'富城' , '黎'=&gt;'明'); //数组有四个元素<br/>　foreach( $myarr as $key =&gt; $value ) //然后开始循环 每一次循环将抽取一个值并赋给 $value和key<br/>　{<br/>　　echo &quot;姓氏: $key -- 名: $value&lt;br&gt;&quot;; <br/>　}<br/>?&gt;</pre></p><p>运行后输出的结果： <br /><br/>姓氏: 刘 -- 名: 德华<br /><br/>姓氏: 张 -- 名: 学友<br /><br/>姓氏: 郭 -- 名: 富城<br /><br/>姓氏: 黎 -- 名: 明<br /><br/>　　</p><p>　　　　　　　　　　　　　　　　　　　　 数组还得多玩。才能熟练。。。记住了哦。。。加油</p><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html" target="_blank">继续阅读《PHP 数组array和foreach的应用(第六节)》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/php.html">(U:)传统学习PHP</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%AD%A6%E4%B9%A0php">学习php</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E6%95%B0%E7%BB%84">数组</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E9%98%B5%E5%88%97">阵列</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=array">array</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=foreach">foreach</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-fopen-fclose-filesize.html" title="PHP学习笔记2-文件、数组、字符串">PHP学习笔记2-文件、数组、字符串</a>&nbsp;&nbsp;(2010-6-4 15:20:12)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html" title="PHP 函数Finction与全局变量(第七节)">PHP 函数Finction与全局变量(第七节)</a>&nbsp;&nbsp;(2010-3-30 2:43:25)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html" title="PHP 循环语句For_While_DoWhile(第五节)">PHP 循环语句For_While_DoWhile(第五节)</a>&nbsp;&nbsp;(2010-3-29 3:21:3)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html" title="PHP 判断语句switch(第四节)">PHP 判断语句switch(第四节)</a>&nbsp;&nbsp;(2010-3-29 3:11:22)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html" title="PHP 变量的补充(第三节)">PHP 变量的补充(第三节)</a>&nbsp;&nbsp;(2010-3-29 3:1:45)</p></ul>]]></description><category>(U:)传统学习PHP</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=305</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=305&amp;key=f32c20db</trackback:ping></item><item><title>PHP 循环语句For_While_DoWhile(第五节)</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html</link><pubDate>Mon, 29 Mar 2010 03:21:03 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html</guid><description><![CDATA[<p><span style="color: #ff0000">作者：心动吧明生KISS</span></p><p align="center">这一节主要是讲php的循环。。在写程序当中是必不可写的吧。。如果没用到那只能说明你的是小程序啦！哈哈。。</p><p align="center">不过开始之前请允许我介绍几个函数 <span class="STYLE1"><strong><font color="#ff0000">break</font></strong></span> 和 <span class="STYLE1"><strong><font color="#ff0000">continue</font></strong></span> 前者的作用：在循环到某一条值的时候你想退出这个循环程序块可以使用 break,</p><p align="center">如果你只是想让此次的循环不执行某一次的操作而想让他继续循环下去的就可以用continue.. 可能在这里说得有点不太清楚。我们现在开始进行操作一下吧</p><p class="STYLE2">For 循环的使用</p><div class="codes"><pre class="php" name="code">&lt;?<br/>　for($a=1;$a&lt;5;$a++) //从1开始循环，循环到5 ，每次循环递增1<br/>　{<br/>　　echo &quot;结果：$a&lt;br&gt;&quot;;<br/>　}<br/>?&gt; </pre></div><p>结果：1<br /><br/>结果：2<br /><br/>结果：3<br /><br/>结果：4<br /><br/>&nbsp;</p><p>明生注释：在使用这个的时候需要注意的是他不像其他的程序 如：asp中的for a=0 to 100 其实这样挺好理解的。但是换成php也差不多吧。只是二种写法不一样意思都是一样的........但是他的写法和javascript是一模一样的。哈哈还是有相同的。现在来看第二种循环..While</p><p class="STYLE2">While 循环的使用</p><div class="codes"><pre class="php" name="code">&lt;?<br/>　$a = 1;<br/>　while($a&lt;5) //判断a是不是小于5,如果小于5就继续循环下去<br/>　{<br/>　　echo &quot;结果：$a&lt;br&gt;&quot;;<br/>　　$a++; //注意这里需要让他加1 要不然会死循环 <br/>　}<br/>?&gt; </pre></div><p>结果：1<br /><br/>结果：2<br /><br/>结果：3<br /><br/>结果：4<br /><br/>&nbsp;</p><p>明生注释：在使用while的当中。他是可以根据条件来进行循环的。也就是说只有条件为真的时候就会继续循环下去。否则跳出... 看看他的孪生兄弟。。do..while</p><p><span class="STYLE2"><strong><font color="#0000ff">Do While 循环的使用 </font></strong></span></p><div class="codes"><pre class="php" name="code">&lt;?<br/>　$a = 99;<br/>　do //无论任何条件都会运行一次<br/>　{<br/>　　echo &quot;A的值: $a ..只运行一次吧&quot;;<br/>　　$a++; <br/>　}<br/>　while($a&lt;5) //然后才开始判断.<br/>?&gt; </pre></div><p>运行后输出的结果： A的值: 99 ..只运行一次吧</p><p>明生注释：在使用do while的时候得注意无论什么时候都会先运行一次。然后才开始判断循环......时间不多。继续看一下跳出和下一次循环的函数和操作</p><p class="STYLE2">Break 和 continue 在循环中的使用</p><p class="STYLE4">下面是 break 在循环中的使用 此次只循环二次.因为判断了是不是等于3如果等等于就退出循环.所以输出的结果应为2次</p><div class="codes"><pre class="php" name="code">&lt;?<br/>　for($a=1;$a&lt;5;$a++) //从1开始循环5次，每次递增1<br/>　{<br/>　　　if( $a == 3 ) break; //判断$a的值是不是和3相等.如果相等就用 break 退出循环<br/>　　　echo &quot;循环第: $a 次 &lt;br&gt;&quot;;<br/>　}<br/>?&gt; </pre></div><p>循环第: 1 次 <br /><br/>循环第: 2 次 <br /><br/>&nbsp;</p><p class="STYLE4">下面是 continue 在循环中的使用此次只循环四次.但当中判断了一如果值为3就跳过的判断。所以只输出4次</p><div class="codes"><pre class="php" name="code">&lt;? <br/>　for($a=1;$a&lt;5;$a++)<br/>　{<br/>　　　if( $a == 3 ) continue; //判断$a的值是不是和3相等.如果相等就用 continue 跳过此次循环直到下一次<br/>　　　echo &quot;循环第: $a 次 &lt;br&gt;&quot;;<br/>　} <br/>?&gt; </pre></div><p>循环第: 1 次 <br /><br/>循环第: 2 次 <br /><br/>循环第: 4 次 <br /><br/>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>　　　　　　　　好了。这一节学完之后。也该休息一下了。。。今天比较累。所以早点睡了。有事情群里说或在这里留言。各位晚安.加油</p><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html" target="_blank">继续阅读《PHP 循环语句For_While_DoWhile(第五节)》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/php.html">(U:)传统学习PHP</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%AD%A6%E4%B9%A0php">学习php</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=Do%2E%2Ewhile%E5%BE%AA%E7%8E%AF">Do..while循环</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=while%E5%BE%AA%E7%8E%AF">while循环</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=for%E5%BE%AA%E7%8E%AF">for循环</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=php%E5%BE%AA%E7%8E%AF">php循环</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html" title="PHP 函数Finction与全局变量(第七节)">PHP 函数Finction与全局变量(第七节)</a>&nbsp;&nbsp;(2010-3-30 2:43:25)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html" title="PHP 数组array和foreach的应用(第六节)">PHP 数组array和foreach的应用(第六节)</a>&nbsp;&nbsp;(2010-3-29 4:22:37)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html" title="PHP 判断语句switch(第四节)">PHP 判断语句switch(第四节)</a>&nbsp;&nbsp;(2010-3-29 3:11:22)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html" title="PHP 变量的补充(第三节)">PHP 变量的补充(第三节)</a>&nbsp;&nbsp;(2010-3-29 3:1:45)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-if-else.html" title="PHP 判断语句IF..else(第二节)">PHP 判断语句IF..else(第二节)</a>&nbsp;&nbsp;(2010-3-28 1:24:17)</p></ul>]]></description><category>(U:)传统学习PHP</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=304</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=304&amp;key=f56aa280</trackback:ping></item><item><title>PHP 判断语句switch(第四节)</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html</link><pubDate>Mon, 29 Mar 2010 03:11:22 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html</guid><description><![CDATA[<p><span style="color: #ff0000">作者：心动吧明生KISS</span></p><p>其实这一节没啥好说的。只是很简单的写一个公式并记录下来。以后方便查询。。。switch和if的区别是.他是简式化的。如果你有五条以上的判断那你是不是需要写很多的elseif 但如果用到switch就不需要了。..好现在我们来学习一下如何使用他</p><div class="codes"><pre class="php" name="code">&lt;?<br/>　$a = 3; //一个名为A变量的值是3<br/><br/>　switch($a) //然后开始判断$a的值是什么 <br/>　{<br/>　case 1: //如果是1就输出下面的 <br/>　　echo 'A 的值是 1';<br/>　　break;<br/>　case 2: //否则一下判断下面 <br/>　　echo 'A 的值是 2';<br/>　　break;<br/>　case 3:<br/>　　echo 'A 的值是 3';<br/>　　break;<br/>　case 4:<br/>　　echo 'A 的值是 4';<br/>　　break;<br/>　default:<br/>　　echo 'A 的值什么都不是';<br/>　　break; <br/>　}<br/>?&gt; </pre></div><p>运行后输出的结果： A 的值是 3</p><p>明生注释：从当中我们可以看到。如果想判断一条数据的多种可能性。我们可以使用switch。这样大大的方便了我们。也减少出错的可能性。。不过在写的当中要注意一些。。首先我们看到 <span class="STYLE1"><strong><font color="#ff0000">switch()</font></strong></span> 必须要用括号。而后面并没有 <span class="STYLE1"><strong><font color="#ff0000">; </font></strong></span>结束,然后通过 <span class="STYLE2"><strong><font color="#ff0000">{ }</font></strong></span> 将当中代码包住。 在判断的时候需要用到 <span class="STYLE1"><strong><font color="#ff0000">case 值</font></strong></span> 并且以 <span class="STYLE2"><strong><font color="#ff0000">:</font></strong></span> 为开始 以<span class="STYLE2"><strong><font color="#ff0000"> break;</font></strong></span> 为结束的一种怪异写法..其实慢慢看是可以理解的。</p><p>　　　　为什么一定要用break;结束呢。你可以做一个这样的实验。你将上面的代码去除break;然后运行一次。你会看到显示出来的并不止 <strong>'A 的值是 3'</strong> 还会有下面的 <strong>'A 的值是 4'</strong>和<strong> 'A 的值什么都不是'</strong> 从这一点看来。break;的作用是让程序知道如果到了这一块执行完后就跳出.....而最后的一个<span class="STYLE2"><strong><font color="#ff0000">default</font></strong></span>的作用又是什么呢。它和if 当中的 else是一样的。就是说所有条件都不成立的时候就执行他。。。好了。你学会了吗。。。。别忘了这里是心动吧哦。看完留个言吧。。。。谢谢</p><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html" target="_blank">继续阅读《PHP 判断语句switch(第四节)》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/php.html">(U:)传统学习PHP</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%AD%A6%E4%B9%A0php">学习php</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=SWitch">SWitch</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%88%A4%E6%96%AD%E8%AF%AD%E5%8F%A5">判断语句</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html" title="PHP 函数Finction与全局变量(第七节)">PHP 函数Finction与全局变量(第七节)</a>&nbsp;&nbsp;(2010-3-30 2:43:25)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html" title="PHP 数组array和foreach的应用(第六节)">PHP 数组array和foreach的应用(第六节)</a>&nbsp;&nbsp;(2010-3-29 4:22:37)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html" title="PHP 循环语句For_While_DoWhile(第五节)">PHP 循环语句For_While_DoWhile(第五节)</a>&nbsp;&nbsp;(2010-3-29 3:21:3)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html" title="PHP 变量的补充(第三节)">PHP 变量的补充(第三节)</a>&nbsp;&nbsp;(2010-3-29 3:1:45)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-if-else.html" title="PHP 判断语句IF..else(第二节)">PHP 判断语句IF..else(第二节)</a>&nbsp;&nbsp;(2010-3-28 1:24:17)</p></ul>]]></description><category>(U:)传统学习PHP</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=303</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=303&amp;key=9ea50efb</trackback:ping></item><item><title>PHP 变量的补充(第三节)</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html</link><pubDate>Mon, 29 Mar 2010 03:01:45 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html</guid><description><![CDATA[<p><span style="color: #ff0000">作者：心动吧明生KISS</span></p><p>其实这一课是补回第一课的。因为第一课只是很随便的讲了一下变量。就是想让大家容易一点上手。而这一节就不一样了。讲PHP的变量其他的操作方式。 首先我们都知道 = 是一种赋值语句. 而如果我要将某个变量再与其他的值相加的时候是不是需要 A变量 = A变量 + 某值 但是在php当中是不需要的（也可以像上面那样写）.. 好了。现在进入主题</p><p class="STYLE1">第一个主题 : 如何将自身相加 +=</p><div class="codes"><pre class="php" name="code">&lt;?<br/>　$a = 1; //A的值为1 <br/>　$b = 1; //A的值为1 <br/><br/>　$a += 1; //而 $a += 1; 就相当于 $a = $a + 1; 简写了看明白了吗 如果是想让自身加1 还可以使用 $a++; 就可以了 <br/>　$b = $b + 1; //看得出来这样写也是对的。但是和上面相对比是不是麻烦了一些 <br/><br/>　echo '输出 $a 的结果' . $a . '&lt;br&gt;'; //二者输出的结果是一样的 同为 : 2 <br/>　echo '输出 $b 的结果' . $b . '&lt;br&gt;';<br/>?&gt; </pre></div><p>输出 $a 的结果2<br /><br/>输出 $b 的结果2<br /><br/>&nbsp;</p><p>明生注释：从上面来看。我们可以得出一个结论就是,简写可以帮助减轻我们的工作。还可以防止写错的机会。。暂进没想到其他的。哈哈。好现在我们再看看其余的。有相加肯定就有相减吧。。。嗯。你答对了。。</p><p class="STYLE1">第二个主题 : 如何将自身相减 -=<br /><br/>&nbsp;</p><div class="codes"><pre class="php" name="code">&lt;?<br/>　$a = 1; //A的值为1 <br/>　$b = 1; //A的值为1 <br/><br/>　$a -= 1; //而 $a -= 1; 就相当于 $a = $a - 1; 简写了看明白了吗 <br/>　$b = $b + 1; //看得出来这样写也是对的。但是和上面相对比是不是麻烦了一些 <br/><br/>　echo '输出 $a 的结果' . $a . '&lt;br&gt;'; //二者输出的结果是一样的 同为 : 0 <br/>　echo '输出 $b 的结果' . $b . '&lt;br&gt;';<br/>?&gt; </pre></div><p>输出 $a 的结果0<br /><br/>输出 $b 的结果0<br /><br/>&nbsp;</p><p>明生注释：其实和上面一样。没啥好解释的...其余的剩和除。在下面会给出一个表。自己看吧。。不过如果我想将二个数联合起来可不能用<span class="STYLE3"><strong><font color="#ff0000"> +</font></strong></span> 号。得用啥 肯定是 <span class="STYLE3"><strong><font color="#ff0000">.</font></strong></span> 嘛</p><p><span class="STYLE1"><strong><font color="#0000ff">第三个主题 : 如何将自身和某值相连</font></strong></span><br /><br/>&nbsp;</p><div class="codes"><pre class="php" name="code">&lt;?<br/>　$a = '中国';<br/>　$b = '人们';<br/>　$c = '中国';<br/>　$d = '人们';<br/><br/>　$a .= $b; //将$a的自身值与$b相连.如同下面的一个道理 <br/><br/>　$c = $c . $d; //将$c的自身值与$d相连 然后再将值赋给$c<br/><br/>　echo '输出 $a 的结果' . $a . '&lt;br&gt;';<br/>　echo '输出 $c 的结果' . $c . '&lt;br&gt;';<br/>?&gt;</pre></div><p>输出 $a 的结果中国人们<br /><br/>输出 $c 的结果中国人们<br /><br/>&nbsp;</p><p>&nbsp;</p><p>　　　　　　　　　　其实都差不多。只是一种补充。还有很多在这里就不能一列一列的出来。要不然很久都看不完。。加油！！！！</p><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html" target="_blank">继续阅读《PHP 变量的补充(第三节)》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/php.html">(U:)传统学习PHP</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%AD%A6%E4%B9%A0php">学习php</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%8F%98%E9%87%8F">变量</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=php%E8%AF%AD%E6%B3%95">php语法</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E9%80%92%E5%A2%9E">递增</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E9%80%92%E5%87%8F">递减</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html" title="PHP 函数Finction与全局变量(第七节)">PHP 函数Finction与全局变量(第七节)</a>&nbsp;&nbsp;(2010-3-30 2:43:25)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html" title="PHP 数组array和foreach的应用(第六节)">PHP 数组array和foreach的应用(第六节)</a>&nbsp;&nbsp;(2010-3-29 4:22:37)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html" title="PHP 循环语句For_While_DoWhile(第五节)">PHP 循环语句For_While_DoWhile(第五节)</a>&nbsp;&nbsp;(2010-3-29 3:21:3)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html" title="PHP 判断语句switch(第四节)">PHP 判断语句switch(第四节)</a>&nbsp;&nbsp;(2010-3-29 3:11:22)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-if-else.html" title="PHP 判断语句IF..else(第二节)">PHP 判断语句IF..else(第二节)</a>&nbsp;&nbsp;(2010-3-28 1:24:17)</p></ul>]]></description><category>(U:)传统学习PHP</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=302</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=302&amp;key=e955d8e2</trackback:ping></item><item><title>PHP 判断语句IF..else(第二节)</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/php/php-if-else.html</link><pubDate>Sun, 28 Mar 2010 01:24:17 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/php/php-if-else.html</guid><description><![CDATA[<p><span style="color: #ff0000">作者:心动吧明生KISS</span></p><p>上一节讲到变量的使用以及一些最最最基础的入门。不知道你回去有没有做成功自己的网页了。要是没有得赶紧动手哦。。。</p><p>今天的这一节是 php 的判断语句 if..else</p><p>　 　 　 　 在现在的程序当中判断语句是必不可少的。所以这一课需要好好的听哦。。最好能边看边动手实践这样容易记一些　 　 　 　 　 　 　 　 　 　</p><p class="STYLE4">案例1 单条件判断 if：</p><div class="codes"><pre class="php" name="code">&lt;?<br/>　$a = 1; //变量$a 的值 为 1<br/>　if( $a &lt; 5 ) //如果a的值小于5<br/>　{<br/>　　echo 'A &lt; 5'; //那么就输出这一段 结果应输出 A &lt; 5<br/>　}<br/>?&gt; </pre></div><p>运行后输出的结果： A &lt; 5</p><p>明生注释：我们先看一下他的判断写法 if() 是使用()来将其括住，然后后面并没有跟上 then 所以和asp,delphi 之类的语言有些区别，不过他的语法倒是和javascript的非常相似,相似度起码有百分80左右..也就是说学过javascript的能很容易看懂这些。肯定也有一些出入。不过我们慢慢看下去就觉得其实程序都差不多。思路其实都一样的只是语法不一样而已。所以不要畏惧不要后退。只要硬着头皮学懂语法。其余的再慢慢操作时候就会加深自己的技术了。 跑题了。。现在来看看语法</p><p>if (这里写条件) 　　　注意一点是。不要在这后面带 ; 要不然会认为这语句结束了。。得注意了。</p><p>{ 用<span class="STYLE3"><strong><font color="#ff0000">{</font></strong></span>开始</p><p>　　中间写代码</p><p>} 以<span class="STYLE3"><strong><font color="#ff0000">}</font></strong></span>结束</p><p>现在我们再来看看下面的双条件判断。。。。。</p><p class="STYLE4">案例2 多条件判断if..else：</p><div class="codes"><pre class="php" name="code">&lt;?<br/>$a = 6; //一样声明一个$a 值为 1<br/>if($a &lt; 5) //如果a的值小于 5<br/>{<br/>echo 'A &lt; 5'; //那么就输出这一段 <br/>} <br/>else<br/>{<br/>echo 'A &gt; 5'; //如果大于5就输出这一段<br/>}<br/>// 结果应输出 A &gt; 5 <br/>?&gt; </pre></div><p>运行后输出的结果： A &gt; 5</p><p>明生注释：首先一个变量A的值为6,然后开始判断他是不是小于5 由于A的值大于5 所以并没有执行当中的。而是跳到else程序块.从这里可以看出来。如果条件1不成立就执行条件2,但如果我有多个条件的时候该怎么办呢。。好下面就会看到如何判断多条的</p><p class="STYLE5"><strong>案例3 多条件判断if..elseif...else:</strong></p><div class="codes"><pre class="php" name="code">&lt;?<br/>$a = 3; //一样声明一个$a 值为 3<br/>if($a == 1) //判断是不是相等.如果相等就执行下面的<br/>{<br/>echo 'A = 1'; //那么就输出这一段 <br/>}<br/>elseif($a == 2) //否则如果相等于2就执行下面的<br/>{<br/>echo 'A = 2';<br/>}<br/>else //无论等于什么数都会执下面的程序块<br/>{ <br/>echo &quot;A = $a&quot;; <br/>}<br/>?&gt; </pre></div><p>运行后输出的结果： A = 3</p><p>明生注释： 先看一下表。。 下面表的内容来自于(php 官方手册简体中文版)电子书</p><p><strong>表格 10-4. 比较运算符</strong><br/><table border="1">    <thead>        <tr>            <th valign="middle" align="left">例子</th>            <th valign="middle" align="left">名称</th>            <th valign="middle" align="left">结果</th>        </tr>    </thead>    <tbody>        <tr>            <td valign="middle" align="left">$a == $b</td>            <td valign="middle" align="left">等于</td>            <td valign="middle" align="left"><strong>TRUE</strong>，如果 $a 等于 $b。</td>        </tr>        <tr>            <td valign="middle" align="left">$a === $b</td>            <td valign="middle" align="left">全等</td>            <td valign="middle" align="left"><strong>TRUE</strong>，如果 $a 等于 $b，并且它们的类型也相同。(PHP 4 only)</td>        </tr>        <tr>            <td valign="middle" align="left">$a != $b</td>            <td valign="middle" align="left">不等</td>            <td valign="middle" align="left"><strong>TRUE</strong>，如果 $a 不等于 $b。</td>        </tr>        <tr>            <td valign="middle" align="left">$a &lt;&gt; $b</td>            <td valign="middle" align="left">不等</td>            <td valign="middle" align="left"><strong>TRUE</strong>，如果 $a 不等于 $b。</td>        </tr>        <tr>            <td valign="middle" align="left">$a !== $b</td>            <td valign="middle" align="left">非全等</td>            <td valign="middle" align="left"><strong>TRUE</strong>，如果 $a 不等于 $b，或者它们的类型不同。(PHP 4 only)</td>        </tr>        <tr>            <td valign="middle" align="left">$a &lt; $b</td>            <td valign="middle" align="left">小与</td>            <td valign="middle" align="left"><strong>TRUE</strong>，如果 $a 严格小于 $b。</td>        </tr>        <tr>            <td valign="middle" align="left">$a &gt; $b</td>            <td valign="middle" align="left">大于</td>            <td valign="middle" align="left"><strong>TRUE</strong>，如果 $a 严格 $b。</td>        </tr>        <tr>            <td valign="middle" align="left">$a &lt;= $b</td>            <td valign="middle" align="left">小于等于</td>            <td valign="middle" align="left"><strong>TRUE</strong>，如果 $a 小于或者等于 $b。</td>        </tr>        <tr>            <td valign="middle" align="left">$a &gt;= $b</td>            <td valign="middle" align="left">大于等于</td>            <td valign="middle" align="left"><strong>TRUE</strong>，如果 $a 大于或者等于 $b。</td>        </tr>    </tbody></table></p><p>从表中可以看出来我们的判断是判断相等。如果相等就执行这个。否则如果执行这个。否则就执行这个。。如果需要一次性判断二个值怎么写呢？？</p><div class="codes"><pre class="php" name="code">&lt;?<br/>$a = 1; //这里就不注释了吧<br/>$b = 2;<br/>if($a == 1 and $b == 2) //如果$a = 2 或 =3 就输出对的. 否则就输出错的 <br/>{<br/>echo '对的';<br/>} <br/>else<br/>{<br/>echo '错的';<br/>}<br/>//结果输出 对的 <br/><br/>if($a == 1 &amp; $b == 2)<br/>{<br/>echo '对的';<br/>}<br/>else<br/>{<br/>echo '错的';<br/>}<br/>//结果输出 对的<br/>?&gt;<br/><br/></pre></div><p>运行后输出的结果：对的对的</p><p>&nbsp;</p><p>明生注释：输出的结果为对的,不知道你有没有发现 有一个 &amp; 其实他的值和and是一样的。只是php里面并不区分而已,还有可以用&amp;&amp;都无所谓的。一样运行。</p><p><strong>表格 10-3. 位运算算</strong><br/><table border="1">    <thead>        <tr>            <th valign="middle" align="left">例子</th>            <th valign="middle" align="left">名称</th>            <th valign="middle" align="left">结果</th>        </tr>    </thead>    <tbody>        <tr>            <td valign="middle" align="left">$a &amp; $b</td>            <td valign="middle" align="left">And（按位与）</td>            <td valign="middle" align="left">将在 $a 和 $b 中都为 1 的位设为 1。</td>        </tr>        <tr>            <td valign="middle" align="left">$a | $b</td>            <td valign="middle" align="left">Or（按位或）</td>            <td valign="middle" align="left">将在 $a 或者 $b 中为 1 的位设为 1。</td>        </tr>        <tr>            <td valign="middle" align="left">$a ^ $b</td>            <td valign="middle" align="left">Xor（按位异或）</td>            <td valign="middle" align="left">将在 $a 和 $b 中不同的位设为 1。</td>        </tr>        <tr>            <td valign="middle" align="left">~ $a</td>            <td valign="middle" align="left">Not（按位非）</td>            <td valign="middle" align="left">将 $a 中为 0 的位设为 1，反之亦然。</td>        </tr>        <tr>            <td valign="middle" align="left">$a &lt;&lt; $b</td>            <td valign="middle" align="left">Shift left（左移）</td>            <td valign="middle" align="left">将 $a 中的位向左移动 $b 次（每一次移动都表示&ldquo;乘以 2&rdquo;）。</td>        </tr>        <tr>            <td valign="middle" align="left">$a &gt;&gt; $b</td>            <td valign="middle" align="left">Shift right（右移）</td>            <td valign="middle" align="left">将 $a 中的位向右移动 $b 次（每一次移动都表示&ldquo;除以 2&rdquo;）。</td>        </tr>    </tbody></table></p><p>不过PHP当中还有一种挺特别的写法。。。现在我们来看看</p><div class="codes"><pre class="php" name="code">&lt;?<br/>　$a = 3; //这里就不注释了吧<br/>　$a &gt; 1 ? $s = '大于1': $s = '小于1';<br/>　echo $s<br/>?&gt;</pre></div><p>运行后输出的结果：大于1</p><p>明生注释：一个A的变量他的值为3 然后进行判断是不是大于1 如果大于就输出'大于1' 否则输出 小于1 ,现在我们来解析这一句话..</p><p>　<span class="STYLE3"><strong><font color="#ff0000">$a &gt; 1 ? $s = '大于1': $s = '小于1'; </font></strong></span></p><p>他这里并没有用到if 但是却可以这样写，用?号来区分他的值,用:来代替else 就这么简单。呵呵....</p><p>&nbsp;</p><p align="right">今天的课程就到这里。明天继续学习另一种判断...努力。。努力。。。</p><p align="right">&nbsp;</p><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-if-else.html" target="_blank">继续阅读《PHP 判断语句IF..else(第二节)》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/php.html">(U:)传统学习PHP</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%AD%A6%E4%B9%A0php">学习php</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%88%A4%E6%96%AD%E8%AF%AD%E5%8F%A5">判断语句</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=IF%2E%2Eelse">IF..else</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-if-else.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html" title="PHP 函数Finction与全局变量(第七节)">PHP 函数Finction与全局变量(第七节)</a>&nbsp;&nbsp;(2010-3-30 2:43:25)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html" title="PHP 数组array和foreach的应用(第六节)">PHP 数组array和foreach的应用(第六节)</a>&nbsp;&nbsp;(2010-3-29 4:22:37)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html" title="PHP 循环语句For_While_DoWhile(第五节)">PHP 循环语句For_While_DoWhile(第五节)</a>&nbsp;&nbsp;(2010-3-29 3:21:3)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html" title="PHP 判断语句switch(第四节)">PHP 判断语句switch(第四节)</a>&nbsp;&nbsp;(2010-3-29 3:11:22)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html" title="PHP 变量的补充(第三节)">PHP 变量的补充(第三节)</a>&nbsp;&nbsp;(2010-3-29 3:1:45)</p></ul>]]></description><category>(U:)传统学习PHP</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/php/php-if-else.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=301</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=301&amp;key=d57daa98</trackback:ping></item><item><title>PHP 变量的声明(第一节)</title><author>a@b.com (kissjetg)</author><link>http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang.html</link><pubDate>Sun, 28 Mar 2010 01:19:32 +0800</pubDate><guid>http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang.html</guid><description><![CDATA[<p><span style="color: #ff0000">作者:心动吧明生KISS</span></p><p>php必须是 以<span class="STYLE3"><strong><font color="#ff0000">&lt;?</font></strong></span>开始 　 以<span class="STYLE3"><strong><font color="#ff0000">?&gt;</font></strong></span>为结束 的一种格式语法<br /><br/>他的变量需要用到 $ 来标识出来.如<br /><br/>　　　　　　　　　　　　　　　　　　　　假设: a = 1 那么在php当中就需要 $a = 1 <br /><br/>　　　　　　　　　　　　　　　　　　　　　 上述是ASP　 　 　 　 　 　 　 　 　 　 　</p><p>案例：</p><div class="codes"><pre class="php" name="code">&lt;?<br/>$a = 'aa'; // 声明一个变量为a的并且给他一个值，而值的内容为：aa<br/>$b = 'ccc'; <br/>echo $a . '$b&lt;br&gt;'; //然后用echo输出,因为所使用的''括住当中的$b所以变量b并不能进行转换。<br/>//上面输出的结果应为 aa$b<br/>echo $a . &quot;$b&lt;br&gt;&quot;; //如果使用&quot;&quot;号。那么$b就会被转义成变量的形式输出也就是不会输出$b而是输出ccc <br/>//上面输出的结果应为 aaccc<br/>?&gt; </pre></div><p>运行后输出的结果：aa$b<br /><br/>运行后输出的结果：aaccc<br /><br/>&nbsp;</p><p>在上面的代码有二点需要注意的，</p><p>　 　 　 　 第一：每一行最后必须要以 <span class="STYLE4"><strong><font color="#ff0000">;</font></strong></span> 为结束符　</p><p>　 　 　 　 第二：单引号和双引号的区别 如果使用<span class="STYLE3"><strong><font color="#ff0000">''</font></strong></span>就会当作一切为字符串输出,如果以<span class="STYLE3"><strong><font color="#ff0000">&quot;&quot;</font></strong></span>那么输出的时候就会以一种代码形式输出，也就是某串字符里面有一个变量他就会将他以变量的形式帮你输出。而不会当成字符串。这里解释得有点笼统。。你可以将上面的那段代码放进iis或者某个页面上试一下就会明白了..</p><p>　 　 　 　 第三：还有当的中 <span class="STYLE5"><font color="#ff0000">.</font></span> 是什么意思呢 就相当于asp 当中的 &amp; 一样 (连接符)　delphi 当中的是 +</p><p>　 　 　 　 第四：如果你注释掉某条字符可以用 <span class="STYLE3"><strong><font color="#ff0000">//</font></strong></span> 如果有多行可以用<span class="STYLE3"><strong><font color="#ff0000"> /*　 　 */</font></strong></span>　 　 　 　</p><p>　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 　 好了有什么不明白的。可以加我的群: 8036083　 　 　</p><p>Copyright © 2008</p><p><a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang.html" target="_blank">继续阅读《PHP 变量的声明(第一节)》的全文内容...</a></p><p>分类: <a href="http://www.abcxd.com/abcxd/abcxdArticle/php.html">(U:)传统学习PHP</a> | Tags: <a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%AD%A6%E4%B9%A0php">学习php</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=%E5%8F%98%E9%87%8F">变量</a>&nbsp;&nbsp;<a href="http://www.abcxd.com/abcxd/catalog.asp?tags=php%E8%AF%AD%E6%B3%95">php语法</a>&nbsp;&nbsp; | <a href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang.html#comment" target="_blank">添加评论</a>(0)</p><h3>相关文章:</h3><ul><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-Finction.html" title="PHP 函数Finction与全局变量(第七节)">PHP 函数Finction与全局变量(第七节)</a>&nbsp;&nbsp;(2010-3-30 2:43:25)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-array-foreach.html" title="PHP 数组array和foreach的应用(第六节)">PHP 数组array和foreach的应用(第六节)</a>&nbsp;&nbsp;(2010-3-29 4:22:37)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-For_While_DoWhile.html" title="PHP 循环语句For_While_DoWhile(第五节)">PHP 循环语句For_While_DoWhile(第五节)</a>&nbsp;&nbsp;(2010-3-29 3:21:3)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-switch.html" title="PHP 判断语句switch(第四节)">PHP 判断语句switch(第四节)</a>&nbsp;&nbsp;(2010-3-29 3:11:22)</p><p><a  href="http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang1.html" title="PHP 变量的补充(第三节)">PHP 变量的补充(第三节)</a>&nbsp;&nbsp;(2010-3-29 3:1:45)</p></ul>]]></description><category>(U:)传统学习PHP</category><comments>http://www.abcxd.com/abcxd/abcxdArticle/php/php-bianliang.html#comment</comments><wfw:comment>http://www.abcxd.com/abcxd/</wfw:comment><wfw:commentRss>http://www.abcxd.com/abcxd/feed.asp?cmt=300</wfw:commentRss><trackback:ping>http://www.abcxd.com/abcxd/cmd.asp?act=tb&amp;id=300&amp;key=c1839398</trackback:ping></item></channel></rss>
