Maison développement back-end tutoriel php MordenPHP阅览笔记(一)——先跑再说,跑累了再走

MordenPHP阅览笔记(一)——先跑再说,跑累了再走

Jun 13, 2016 pm 12:29 PM
feature function public resource this

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>
Copier après la connexion

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> }
Copier après la connexion

二、使用接口

接口,本来没太懂,看懂了之后简直了,牛逼啊!

一个接口,大家只要遵守接口规定,就都能用,就这么个意思。

下面是一个获得内容的接口示例,还可以写更多基于此接口的模块;(其中,模块中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());
Copier après la connexion

 另一个模块

<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> }
Copier après la connexion

 

 三、性状

奇怪的东西。。。

其实就是为了多重继承或者一对多个不同的类别吧

<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();
Copier après la connexion

 

 四、生成器

直接上代码

<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>
Copier après la connexion

 

 五、闭包

这里闭包基本等于匿名函数

<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>);
Copier après la connexion

 六、附加状态

这个没搞懂。。。

(二)标准

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> }
Copier après la connexion

 

----------------------

后面的都是讲述的东西,有需要的我再写吧。 

 

Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn

Outils d'IA chauds

Undresser.AI Undress

Undresser.AI Undress

Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover

AI Clothes Remover

Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool

Undress AI Tool

Images de déshabillage gratuites

Clothoff.io

Clothoff.io

Dissolvant de vêtements AI

AI Hentai Generator

AI Hentai Generator

Générez AI Hentai gratuitement.

Article chaud

R.E.P.O. Crystals d'énergie expliqués et ce qu'ils font (cristal jaune)
3 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Meilleurs paramètres graphiques
3 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Comment réparer l'audio si vous n'entendez personne
3 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: Comment déverrouiller tout dans Myrise
3 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌

Outils chauds

Bloc-notes++7.3.1

Bloc-notes++7.3.1

Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise

SublimeText3 version chinoise

Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1

Envoyer Studio 13.0.1

Puissant environnement de développement intégré PHP

Dreamweaver CS6

Dreamweaver CS6

Outils de développement Web visuel

SublimeText3 version Mac

SublimeText3 version Mac

Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Que signifie fonction ? Que signifie fonction ? Aug 04, 2023 am 10:33 AM

Fonction signifie fonction. Il s'agit d'un bloc de code réutilisable avec des fonctions spécifiques. C'est l'un des composants de base d'un programme. Il peut accepter des paramètres d'entrée, effectuer des opérations spécifiques et renvoyer des résultats. code pour améliorer la réutilisabilité et la maintenabilité du code.

Quelle est la différence entre la version développeur et la version publique d'iOS ? Quelle est la différence entre la version développeur et la version publique d'iOS ? Mar 01, 2024 pm 12:55 PM

Chaque année, avant qu'Apple ne publie une nouvelle version majeure d'iOS et de macOS, les utilisateurs peuvent télécharger la version bêta plusieurs mois à l'avance pour en faire l'expérience en premier. Étant donné que le logiciel est utilisé à la fois par le public et par les développeurs, Apple a lancé des versions développeur et publique, qui sont des versions bêta publiques des versions bêta développeur, pour les deux. Quelle est la différence entre la version développeur et la version publique d’iOS ? Littéralement parlant, la version développeur est une version bêta développeur et la version publique est une version bêta publique. La version développeur et la version publique ciblent des publics différents. La version développeur est utilisée par Apple pour les tests par les développeurs. Vous avez besoin d'un compte développeur Apple pour la télécharger et la mettre à niveau.

Mots originaux réécrits : une découverte inattendue est que ce qui était initialement considéré comme un bug est en réalité une fonctionnalité de la conception de Protobuf. Mots originaux réécrits : une découverte inattendue est que ce qui était initialement considéré comme un bug est en réalité une fonctionnalité de la conception de Protobuf. May 09, 2023 pm 04:22 PM

Salut à tous, je suis génial. Récemment, dans notre projet, nous avons utilisé le format protobuf comme support pour stocker les données. J'ai accidentellement enterré un grand trou pour moi-même, mais il m'a fallu beaucoup de temps pour le découvrir. Introduction à protobuf Le nom complet de protobuf est Protocalbuffers. Il a été développé par Google et constitue un mécanisme multilingue, multiplateforme et évolutif pour la sérialisation des données. Similaire à XML, mais plus petit, plus rapide et plus simple. Il vous suffit de définir une seule fois la façon dont vous souhaitez que vos données soient structurées, puis vous pouvez utiliser ses outils de génération pour générer du code source qui inclut certaines opérations de sérialisation et de désérialisation. Peut être facilement écrit à partir d'une variété de flux de données et en utilisant une variété de langages de programmation

Quel est le but de la fonction « enumerate() » en Python ? Quel est le but de la fonction « enumerate() » en Python ? Sep 01, 2023 am 11:29 AM

Dans cet article, nous découvrirons la fonction enumerate() et le but de la fonction « enumerate() » en Python. Qu'est-ce que la fonction enumerate() ? La fonction enumerate() de Python accepte une collection de données comme paramètre et renvoie un objet d'énumération. Les objets d'énumération sont renvoyés sous forme de paires clé-valeur. La clé est l'index correspondant à chaque élément, et la valeur est les éléments. Syntaxe enumerate(iterable,start) Paramètres iterable - Les données transmises dans la collection peuvent être renvoyées sous forme d'objet d'énumération, appelé iterablestart - Comme son nom l'indique, l'index de départ de l'objet d'énumération est défini par start. si nous ignorons

Explication détaillée du rôle et de la fonction de la table MySQL.proc Explication détaillée du rôle et de la fonction de la table MySQL.proc Mar 16, 2024 am 09:03 AM

Explication détaillée du rôle et de la fonction de la table MySQL.proc MySQL est un système de gestion de bases de données relationnelles populaire. Lorsque les développeurs utilisent MySQL, ils impliquent souvent la création et la gestion de procédures stockées (StoredProcedure). La table MySQL.proc est une table système très importante. Elle stocke les informations relatives à toutes les procédures stockées dans la base de données, y compris le nom, la définition, les paramètres, etc. Dans cet article, nous expliquerons en détail le rôle et les fonctionnalités de la table MySQL.proc

L'utilisation et la fonction de la fonction Vue.use L'utilisation et la fonction de la fonction Vue.use Jul 24, 2023 pm 06:09 PM

Utilisation et fonction de Vue.use Function Vue est un framework frontal populaire qui fournit de nombreuses fonctionnalités et fonctions utiles. L'une d'elles est la fonction Vue.use, qui nous permet d'utiliser des plugins dans les applications Vue. Cet article présentera l'utilisation et la fonction de la fonction Vue.use et fournira quelques exemples de code. L'utilisation de base de la fonction Vue.use est très simple, il suffit de l'appeler avant que Vue ne soit instanciée, en passant le plugin que vous souhaitez utiliser comme paramètre. Voici un exemple simple : //Introduire et utiliser le plug-in

Quel fichier est une ressource ? Quel fichier est une ressource ? Dec 20, 2023 am 11:44 AM

Les fichiers de ressources sont un type spécial de fichier généralement utilisé pour stocker diverses informations sur les ressources dans des applications ou des systèmes d'exploitation. Ils jouent un rôle clé dans le développement d’applications et fournissent un soutien au développement multiplateforme et à l’internationalisation. En utilisant les fichiers de ressources, les développeurs peuvent mieux organiser et gérer les ressources des applications tout en offrant une expérience utilisateur plus riche et plus adaptable aux différents besoins.

Un article qui comprend ce point et rattrape 70% des front-end Un article qui comprend ce point et rattrape 70% des front-end Sep 06, 2022 pm 05:03 PM

Un collègue est resté bloqué à cause d'un bug signalé par ce problème de pointage de Vue2 qui a provoqué l'utilisation d'une fonction de flèche, entraînant l'impossibilité d'obtenir les accessoires correspondants. Il ne le savait pas quand je le lui ai présenté, puis j'ai délibérément regardé le groupe de communication front-end. Jusqu'à présent, au moins 70 % des programmeurs front-end ne le comprennent toujours pas. Aujourd'hui, je vais partager avec. vous ce lien. Si tout n'est pas clair Si vous ne l'avez pas encore appris, s'il vous plaît, faites-moi une grande gueule.

See all articles