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> }
----------------------
后面的都是讲述的东西,有需要的我再写吧。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Function means function. It is a reusable code block with specific functions. It is one of the basic components of a program. It can accept input parameters, perform specific operations, and return results. Its purpose is to encapsulate a reusable block of code. code to improve code reusability and maintainability.

Every year before Apple releases a new major version of iOS and macOS, users can download the beta version several months in advance and experience it first. Since the software is used by both the public and developers, Apple has launched developer and public versions, which are public beta versions of the developer beta version, for both. What is the difference between the developer version and the public version of iOS? Literally speaking, the developer version is a developer test version, and the public version is a public test version. The developer version and the public version target different audiences. The developer version is used by Apple for testing by developers. You need an Apple developer account to download and upgrade it.

Hi everyone, I'm awesome. Recently, in our project, we used protobuf format as a carrier for storing data. I accidentally buried a big hole for myself, but it took me a long time to discover it. Introduction to protobuf The full name of protobuf is Protocalbuffers. It was developed by Google and is a cross-language, cross-platform, and scalable mechanism for serializing data. Similar to XML, but smaller, faster, and simpler. You only need to define once how you want your data to be structured, and then you can use its generation tools to generate source code that includes some serialization and deserialization operations. Can be easily written from a variety of data streams and using a variety of programming languages

In this article, we will learn about enumerate() function and the purpose of “enumerate()” function in Python. What is the enumerate() function? Python's enumerate() function accepts a data collection as a parameter and returns an enumeration object. Enumeration objects are returned as key-value pairs. The key is the index corresponding to each item, and the value is the items. Syntax enumerate(iterable,start) Parameters iterable - The passed in data collection can be returned as an enumeration object, called iterablestart - As the name suggests, the starting index of the enumeration object is defined by start. if we ignore

Detailed explanation of the role and function of the MySQL.proc table. MySQL is a popular relational database management system. When developers use MySQL, they often involve the creation and management of stored procedures (StoredProcedure). The MySQL.proc table is a very important system table. It stores information related to all stored procedures in the database, including the name, definition, parameters, etc. of the stored procedures. In this article, we will explain in detail the role and functionality of the MySQL.proc table

This article will help you interpret the vue source code and introduce why you can use this to access properties in various options in Vue2. I hope it will be helpful to everyone!

A colleague got stuck due to a bug pointed by this. Vue2’s this pointing problem caused an arrow function to be used, resulting in the inability to get the corresponding props. He didn't know it when I introduced it to him, and then I deliberately looked at the front-end communication group. So far, at least 70% of front-end programmers still don't understand it. Today I will share with you this link. If everything is wrong If you haven’t learned it yet, please give me a big mouth.

Usage and Function of Vue.use Function Vue is a popular front-end framework that provides many useful features and functions. One of them is the Vue.use function, which allows us to use plugins in Vue applications. This article will introduce the usage and function of the Vue.use function and provide some code examples. The basic usage of the Vue.use function is very simple, just call it before Vue is instantiated, passing in the plugin you want to use as a parameter. Here is a simple example: //Introduce and use the plug-in
