Maison >développement back-end >tutoriel php >MordenPHP阅览笔记(一)——先跑再说,跑累了再走
MordenPHP阅读笔记(一)——先跑再说,跑累了再走
---恢复内容开始---
后台一大堆半成品,或者是几乎不成的。。。
这本书不错,起码是别人推荐的,然后也是比较新的东西,学哪本不是学嘛,关键是得看。
今儿个网不好,科研所需的代码下不到,看书做笔记吧。
这本书基本将的是5.4版本后的一些新变化,写的浅显易懂,虽然鄙人走的还不顺溜,跑一跑也摔不到哪儿去,跑累了我有的是走的机会~~
(一)特性
一、命名空间
一个文件一个类,用了命名空间方便互相调用;
<span style="color: #008080;"> 1</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 2</span> <span style="color: #008000;">//Namespace</span><span style="color: #008080;"> 3</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 4</span> <span style="color: #000000;">namespace ModernPHP\feature\mingmingkongjian;</span><span style="color: #008080;"> 5</span> <span style="color: #0000ff;">function</span> <span style="color: #008080;">var_dump</span><span style="color: #000000;">(){</span><span style="color: #008080;"> 6</span> <span style="color: #0000ff;">echo</span> "Shit!".""<span style="color: #000000;">;</span><span style="color: #008080;"> 7</span> <span style="color: #000000;">}</span><span style="color: #008080;"> 8</span> <span style="color: #008080;"> 9</span> <span style="color: #800080;">$test</span>="OK"<span style="color: #000000;">;</span><span style="color: #008080;">10</span> <span style="color: #008080;">var_dump</span>(<span style="color: #800080;">$test</span><span style="color: #000000;">);</span><span style="color: #008080;">11</span> \ModernPHP\feature\mingmingkongjian\<span style="color: #008080;">var_dump</span><span style="color: #000000;">();</span><span style="color: #008080;">12</span> <span style="color: #008080;">13</span> <span style="color: #008000;">//</span><span style="color: #008000;">命名空间必须顶头,但一个文件中可以有很多命名空间,然后也可以有子空间</span><span style="color: #008080;">14</span> <span style="color: #008000;">//厂商的命名空间是最顶层的命名空间,用于识别品牌</span><span style="color: #008080;">15</span> <span style="color: #008000;">//旨在解决命名冲突的问题,当然现在应该有比较灵活的其他用法</span><span style="color: #008080;">16</span> <span style="color: #008080;">17</span> <span style="color: #008000;">//一个比较实用的点:导入和别名</span><span style="color: #008080;">18</span> <span style="color: #008000;">//导入另一个文件夹下的类定义,直接用</span><span style="color: #008080;">19</span> <span style="color: #0000ff;">require</span> 'index.php'<span style="color: #000000;">;</span><span style="color: #008080;">20</span> <span style="color: #0000ff;">use</span><span style="color: #000000;"> a\aaa;</span><span style="color: #008080;">21</span> <span style="color: #800080;">$daoru</span>=<span style="color: #0000ff;">new</span><span style="color: #000000;"> aaa;</span><span style="color: #008080;">22</span> <span style="color: #800080;">$daoru</span>-><span style="color: #000000;">send();</span><span style="color: #008080;">23</span> <span style="color: #008000;">//</span><span style="color: #008000;">use是导入,然后在use中设置最懒的别名</span><span style="color: #008080;">24</span> <span style="color: #008000;">//另外,5.6版本后可以实现use 函数</span><span style="color: #008080;">25</span> <span style="color: #008000;">// use func a\call;</span><span style="color: #008080;">26</span> <span style="color: #008000;">// \a\call();</span>
index.php
<span style="color: #008080;"> 1</span> <span style="color: #000000;">php</span><span style="color: #008080;"> 2</span> <span style="color: #000000;">namespace a;</span><span style="color: #008080;"> 3</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> aaa{</span><span style="color: #008080;"> 4</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> send(){</span><span style="color: #008080;"> 5</span> <span style="color: #0000ff;">echo</span> "ok"<span style="color: #000000;">;</span><span style="color: #008080;"> 6</span> <span style="color: #000000;"> }</span><span style="color: #008080;"> 7</span> <span style="color: #000000;">}</span><span style="color: #008080;"> 8</span> <span style="color: #008080;"> 9</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> call(){</span><span style="color: #008080;">10</span> <span style="color: #0000ff;">echo</span> "func_use is successful."<span style="color: #000000;">;</span><span style="color: #008080;">11</span> }
二、使用接口
接口,本来没太懂,看懂了之后简直了,牛逼啊!
一个接口,大家只要遵守接口规定,就都能用,就这么个意思。
下面是一个获得内容的接口示例,还可以写更多基于此接口的模块;(其中,模块中getContent的我基本都不会。。。哭)
<span style="color: #000000;">php</span><span style="color: #008000;">//</span><span style="color: #008000;">//Chapter2.P19//Feature_Interface//</span><span style="color: #000000;">namespace ModernPHP\feature\jiekou;</span><span style="color: #0000ff;">class</span><span style="color: #000000;"> DocumentStore{ </span><span style="color: #0000ff;">protected</span> <span style="color: #800080;">$data</span>=<span style="color: #000000;">[]; </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> addDocument(Documentable <span style="color: #800080;">$document</span>){ <span style="color: #008000;">//</span><span style="color: #008000;">这里注明只能使用接口的参数</span> <span style="color: #800080;">$key</span>=<span style="color: #800080;">$document</span>-><span style="color: #000000;">getID(); </span><span style="color: #800080;">$value</span>=<span style="color: #800080;">$document</span>-><span style="color: #000000;">getContent(); </span><span style="color: #800080;">$this</span>->data[<span style="color: #800080;">$key</span>]=<span style="color: #800080;">$value</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getDocuments(){ </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>-><span style="color: #000000;">data; }}</span><span style="color: #0000ff;">interface</span> Documentable{ <span style="color: #008000;">//</span><span style="color: #008000;">定义接口,说白了就是定规矩,其他地方要用,就得说一声</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getId(); </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getContent();}</span><span style="color: #0000ff;">class</span> HtmlDocument <span style="color: #0000ff;">implements</span> Documentable{ <span style="color: #008000;">//</span><span style="color: #008000;">声明要用接口;这个是获得url的内容的</span> <span style="color: #0000ff;">protected</span> <span style="color: #800080;">$url</span><span style="color: #000000;">; </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> __construct(<span style="color: #800080;">$url</span><span style="color: #000000;">){ </span><span style="color: #800080;">$this</span>->url=<span style="color: #800080;">$url</span><span style="color: #000000;">; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getId(){ </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>-><span style="color: #000000;">url; } </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getContent(){ </span><span style="color: #800080;">$ch</span>=curl_init(); <span style="color: #008000;">//</span><span style="color: #008000;">这里的curl是针对url进行操作一个库(相当于)。这个命令是开启一个curl对话,所以下面这些都是一个对话</span> curl_setopt(<span style="color: #800080;">$ch</span>, CURLOPT_URL, <span style="color: #800080;">$this</span>-><span style="color: #000000;">url); curl_setopt(</span><span style="color: #800080;">$ch</span>, CURLOPT_RETURNTRANSFER, 1<span style="color: #000000;">); curl_setopt(</span><span style="color: #800080;">$ch</span>,CURLOPT_CONNECTTIMEOUT,3<span style="color: #000000;">); curl_setopt(</span><span style="color: #800080;">$ch</span>,CURLOPT_FOLLOWLOCATION,1<span style="color: #000000;">); curl_setopt(</span><span style="color: #800080;">$ch</span>,CURLOPT_MAXREDIRS,3<span style="color: #000000;">); </span><span style="color: #800080;">$html</span>=curl_exec(<span style="color: #800080;">$ch</span>); <span style="color: #008000;">//</span><span style="color: #008000;">由这个命令执行刚才的对话</span> curl_close(<span style="color: #800080;">$ch</span><span style="color: #000000;">); </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$html</span><span style="color: #000000;">; }}</span><span style="color: #800080;">$documentStore</span>=<span style="color: #0000ff;">new</span><span style="color: #000000;"> DocumentStore();</span><span style="color: #800080;">$htmlDoc</span>=<span style="color: #0000ff;">new</span> HtmlDocument('http://www.baidu.com'<span style="color: #000000;">);</span><span style="color: #800080;">$documentStore</span>->addDocument(<span style="color: #800080;">$htmlDoc</span><span style="color: #000000;">);</span><span style="color: #008080;">print_r</span>(<span style="color: #800080;">$documentStore</span>->getDocuments());
另一个模块
<span style="color: #008080;"> 1</span> <span style="color: #0000ff;">class</span> StreamDocument <span style="color: #0000ff;">implements</span> Documentable{ <span style="color: #008000;">//</span><span style="color: #008000;">流媒体</span><span style="color: #008080;"> 2</span> <span style="color: #0000ff;">protected</span> <span style="color: #800080;">$resource</span><span style="color: #000000;">;</span><span style="color: #008080;"> 3</span> <span style="color: #0000ff;">protected</span> <span style="color: #800080;">$buffer</span>; <span style="color: #008000;">//</span><span style="color: #008000;">缓冲区大小</span><span style="color: #008080;"> 4</span> <span style="color: #008080;"> 5</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span> __construct(<span style="color: #800080;">$resource</span>,<span style="color: #800080;">$buffer</span>=4096<span style="color: #000000;">){</span><span style="color: #008080;"> 6</span> <span style="color: #800080;">$this</span>-><span style="color: #0000ff;">resource</span>=<span style="color: #800080;">$resource</span><span style="color: #000000;">;</span><span style="color: #008080;"> 7</span> <span style="color: #800080;">$this</span>->buffer=<span style="color: #800080;">$buffer</span><span style="color: #000000;">;</span><span style="color: #008080;"> 8</span> <span style="color: #000000;"> }</span><span style="color: #008080;"> 9</span> <span style="color: #008080;">10</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getId(){</span><span style="color: #008080;">11</span> <span style="color: #0000ff;">return</span> 'resource-'.(int)<span style="color: #800080;">$this</span>-><span style="color: #0000ff;">resource</span><span style="color: #000000;">;</span><span style="color: #008080;">12</span> <span style="color: #000000;"> }</span><span style="color: #008080;">13</span> <span style="color: #008080;">14</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getContent(){</span><span style="color: #008080;">15</span> <span style="color: #800080;">$streamContent</span>=''<span style="color: #000000;">;</span><span style="color: #008080;">16</span> <span style="color: #008080;">rewind</span>(<span style="color: #800080;">$this</span>-><span style="color: #0000ff;">resource</span>); <span style="color: #008000;">//</span><span style="color: #008000;">rewind() 函数将文件指针的位置倒回文件的开头</span><span style="color: #008080;">17</span> <span style="color: #0000ff;">while</span> (<span style="color: #008080;">feof</span>(<span style="color: #800080;">$this</span>-><span style="color: #0000ff;">resource</span>)===<span style="color: #0000ff;">false</span>){ <span style="color: #008000;">//</span><span style="color: #008000;">feof() 函数检测是否已到达文件末尾 (eof)。</span><span style="color: #008080;">18</span> <span style="color: #800080;">$streamContent</span>.=<span style="color: #008080;">fread</span>(<span style="color: #800080;">$this</span>-><span style="color: #0000ff;">resource</span>,<span style="color: #800080;">$this</span>-><span style="color: #000000;">buffer);</span><span style="color: #008080;">19</span> <span style="color: #000000;"> }</span><span style="color: #008080;">20</span> <span style="color: #008080;">21</span> <span style="color: #0000ff;">return</span> <span style="color: #800080;">$streamContent</span><span style="color: #000000;">;</span><span style="color: #008080;">22</span> <span style="color: #000000;"> }</span><span style="color: #008080;">23</span> }
三、性状
奇怪的东西。。。
其实就是为了多重继承或者一对多个不同的类别吧
<span style="color: #008080;"> 1</span> <span style="color: #000000;">php</span><span style="color: #008080;"> 2</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 3</span> <span style="color: #008000;">//Chapter2.P23</span><span style="color: #008080;"> 4</span> <span style="color: #008000;">//Feature_Trait</span><span style="color: #008080;"> 5</span> <span style="color: #008000;">//性状</span><span style="color: #008080;"> 6</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 7</span> <span style="color: #008080;"> 8</span> <span style="color: #008000;">//前面说的接口,是针对同类型的东西,实现相同的功能的;</span><span style="color: #008080;"> 9</span> <span style="color: #008000;">//这里的性状是针对不同的东西,实现相同的功能</span><span style="color: #008080;">10</span> <span style="color: #008080;">11</span> <span style="color: #008000;">//基本用法如下</span><span style="color: #008080;">12</span> <span style="color: #000000;">trait traitName{</span><span style="color: #008080;">13</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> testThis(){</span><span style="color: #008080;">14</span> <span style="color: #0000ff;">echo</span> "This is how trait works."."<br>"<span style="color: #000000;">;</span><span style="color: #008080;">15</span> <span style="color: #000000;"> }</span><span style="color: #008080;">16</span> <span style="color: #000000;">}</span><span style="color: #008080;">17</span> <span style="color: #008080;">18</span> <span style="color: #000000;">trait traitMore{</span><span style="color: #008080;">19</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> testAgain(){</span><span style="color: #008080;">20</span> <span style="color: #0000ff;">echo</span> "This is multiple use."."<br>"<span style="color: #000000;">;</span><span style="color: #008080;">21</span> <span style="color: #000000;"> }</span><span style="color: #008080;">22</span> <span style="color: #000000;">}</span><span style="color: #008080;">23</span> <span style="color: #008080;">24</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> className{</span><span style="color: #008080;">25</span> <span style="color: #0000ff;">use</span><span style="color: #000000;"> traitName;</span><span style="color: #008080;">26</span> <span style="color: #0000ff;">use</span><span style="color: #000000;"> traitMore;</span><span style="color: #008080;">27</span> <span style="color: #008080;">28</span> <span style="color: #000000;">}</span><span style="color: #008080;">29</span> <span style="color: #008080;">30</span> <span style="color: #800080;">$classMine</span>=<span style="color: #0000ff;">new</span><span style="color: #000000;"> className();</span><span style="color: #008080;">31</span> <span style="color: #800080;">$classMine</span>-><span style="color: #000000;">testThis();</span><span style="color: #008080;">32</span> <span style="color: #800080;">$classMine</span>->testAgain();
四、生成器
直接上代码
<span style="color: #008080;"> 1</span> <span style="color: #000000;">php</span><span style="color: #008080;"> 2</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 3</span> <span style="color: #008000;">//Chapter2.P26</span><span style="color: #008080;"> 4</span> <span style="color: #008000;">//Feature_Generator</span><span style="color: #008080;"> 5</span> <span style="color: #008000;">//生成器</span><span style="color: #008080;"> 6</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 7</span> <span style="color: #008080;"> 8</span> <span style="color: #008000;">//其实就是在函数中使用了yield语句的东西</span><span style="color: #008080;"> 9</span> <span style="color: #008000;">//优点在于节省了内存使用情况</span><span style="color: #008080;">10</span> <span style="color: #008000;">//方法是通过动态分配内存进行循环操作</span><span style="color: #008080;">11</span> <span style="color: #008000;">//典型用处是处理csv类数据文件</span><span style="color: #008080;">12</span> <span style="color: #008080;">13</span> <span style="color: #000000;">namespace ModernPHP\feature\shengchegnqi;</span><span style="color: #008080;">14</span> <span style="color: #008080;">15</span> <span style="color: #0000ff;">function</span> getRows(<span style="color: #800080;">$file</span><span style="color: #000000;">){</span><span style="color: #008080;">16</span> <span style="color: #800080;">$handle</span>=<span style="color: #008080;">fopen</span>(<span style="color: #800080;">$file</span>,'rb'<span style="color: #000000;">);</span><span style="color: #008080;">17</span> <span style="color: #0000ff;">if</span> (<span style="color: #800080;">$handle</span>===<span style="color: #0000ff;">false</span><span style="color: #000000;">){</span><span style="color: #008080;">18</span> <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">Exception</span>(); <span style="color: #008000;">//</span><span style="color: #008000;">抛出错误原因</span><span style="color: #008080;">19</span> <span style="color: #000000;"> }</span><span style="color: #008080;">20</span> <span style="color: #0000ff;">while</span> (<span style="color: #008080;">feof</span>(<span style="color: #800080;">$handle</span>)===<span style="color: #0000ff;">false</span><span style="color: #000000;">) {</span><span style="color: #008080;">21</span> yield <span style="color: #008080;">fgetcsv</span>(<span style="color: #800080;">$handle</span><span style="color: #000000;">);</span><span style="color: #008080;">22</span> <span style="color: #000000;"> }</span><span style="color: #008080;">23</span> <span style="color: #008080;">fclose</span>(<span style="color: #800080;">$handle</span><span style="color: #000000;">);</span><span style="color: #008080;">24</span> <span style="color: #000000;">}</span><span style="color: #008080;">25</span> <span style="color: #008080;">26</span> <span style="color: #0000ff;">foreach</span> (getRows('data.csv') <span style="color: #0000ff;">as</span> <span style="color: #800080;">$row</span><span style="color: #000000;">){</span><span style="color: #008080;">27</span> <span style="color: #008080;">print_r</span>(<span style="color: #800080;">$row</span><span style="color: #000000;">);</span><span style="color: #008080;">28</span> <span style="color: #0000ff;">echo</span> "<br>"<span style="color: #000000;">;</span><span style="color: #008080;">29</span> <span style="color: #000000;">}</span><span style="color: #008080;">30</span> <span style="color: #008000;">//</span><span style="color: #008000;">当数据文件很大时,效果尤其明显</span>
五、闭包
这里闭包基本等于匿名函数
<span style="color: #008080;"> 1</span> <span style="color: #000000;">php</span><span style="color: #008080;"> 2</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 3</span> <span style="color: #008000;">//Chapter2.P29</span><span style="color: #008080;"> 4</span> <span style="color: #008000;">//Feature_ClosePatch</span><span style="color: #008080;"> 5</span> <span style="color: #008000;">//闭包或匿名函数</span><span style="color: #008080;"> 6</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 7</span> <span style="color: #008080;"> 8</span> <span style="color: #008000;">//把函数当作是变量</span><span style="color: #008080;"> 9</span> <span style="color: #008000;">//然后它就可以像变量一样用来用去了。。</span><span style="color: #008080;">10</span> <span style="color: #008000;">//常用做函数和方法的回调</span><span style="color: #008080;">11</span> <span style="color: #008080;">12</span> <span style="color: #000000;">namespace ModernPHP\feature\bibao;</span><span style="color: #008080;">13</span> <span style="color: #800080;">$var</span>=<span style="color: #0000ff;">function</span> (<span style="color: #800080;">$name</span><span style="color: #000000;">){</span><span style="color: #008080;">14</span> <span style="color: #0000ff;">return</span> <span style="color: #008080;">sprintf</span>('Hello %s',<span style="color: #800080;">$name</span><span style="color: #000000;">);</span><span style="color: #008080;">15</span> <span style="color: #000000;">};</span><span style="color: #008080;">16</span> <span style="color: #008080;">17</span> <span style="color: #0000ff;">echo</span> <span style="color: #800080;">$var</span>('Andy'<span style="color: #000000;">);</span><span style="color: #008080;">18</span> <span style="color: #008080;">19</span> <span style="color: #008000;">//</span><span style="color: #008000;">做回调</span><span style="color: #008080;">20</span> <span style="color: #800080;">$array</span>=[2,3,4<span style="color: #000000;">];</span><span style="color: #008080;">21</span> <span style="color: #800080;">$num</span>=<span style="color: #008080;">array_map</span>(<span style="color: #0000ff;">function</span> (<span style="color: #800080;">$number</span>){ <span style="color: #008000;">//</span><span style="color: #008000;">array_map,将函数作用到数组中的每个值上,每个值都乘以本身,并返回带有新值的数组</span><span style="color: #008080;">22</span> <span style="color: #0000ff;">return</span> <span style="color: #800080;">$number</span>+1<span style="color: #000000;">;</span><span style="color: #008080;">23</span> },<span style="color: #800080;">$array</span><span style="color: #000000;">);</span><span style="color: #008080;">24</span> <span style="color: #008080;">print_r</span>(<span style="color: #800080;">$num</span>);
六、附加状态
这个没搞懂。。。
(二)标准
PHP-FIG的一些约定俗成;
---类名称,驼峰式,ShitHappens
---方法名称,驼峰式,但首字母小写,shitHappens
---缩进统一为4个空格
---不写?>结束符号;
---{另起一行;
---命名空间要有空格;
---类中属性和方法必须有可见性声明;
---if等控制性结构后面有空格;
<span style="color: #008080;"> 1</span> <span style="color: #000000;">php</span><span style="color: #008080;"> 2</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 3</span> <span style="color: #008000;">//Chapter3.P44</span><span style="color: #008080;"> 4</span> <span style="color: #008000;">//PHP-FIG puts PSRs</span><span style="color: #008080;"> 5</span> <span style="color: #008000;">//</span><span style="color: #008080;"> 6</span> <span style="color: #008080;"> 7</span> <span style="color: #000000;">namespace ModernPHP\standard\realize;</span><span style="color: #008080;"> 8</span> <span style="color: #008080;"> 9</span> <span style="color: #0000ff;">use</span><span style="color: #000000;"> ModernPHP\feature\bibao;</span><span style="color: #008080;">10</span> <span style="color: #0000ff;">use</span><span style="color: #000000;"> ModernPHP\feature\fujiazhuangtai;</span><span style="color: #008080;">11</span> <span style="color: #008080;">12</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> ShitHappens</span><span style="color: #008080;">13</span> <span style="color: #000000;">{</span><span style="color: #008080;">14</span> <span style="color: #0000ff;">public</span> <span style="color: #800080;">$a</span><span style="color: #000000;">;</span><span style="color: #008080;">15</span> <span style="color: #008080;">16</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> suck()</span><span style="color: #008080;">17</span> <span style="color: #000000;"> {</span><span style="color: #008080;">18</span> <span style="color: #0000ff;">if</span> (<span style="color: #800080;">$this</span>->a===<span style="color: #0000ff;">false</span><span style="color: #000000;">){</span><span style="color: #008080;">19</span> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span><span style="color: #000000;">;</span><span style="color: #008080;">20</span> <span style="color: #000000;"> }</span><span style="color: #008080;">21</span> <span style="color: #000000;"> }</span><span style="color: #008080;">22</span> }
----------------------
后面的都是讲述的东西,有需要的我再写吧。