久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      匯總php7所有版本新特征【推薦】

      PHP7.1新特性

      1. 可為空(Nullable)類型

      參數(shù)以及返回值的類型現(xiàn)在可以通過在類型前加上一個(gè)問號使之允許為空。當(dāng)啟用這個(gè)特性時(shí),傳入的參數(shù)或者函數(shù)返回的結(jié)果要么是給定的類型,要么是null

      #php5 function($a = null){   if($a===null) {     return null;   }   return $a; }  #php7+ function fun() :?string {   return null; }  function fun1(?$a) {   var_dump($a); } fun1(null);//null fun1('1');//1

      2. void 類型

      返回值聲明為 void 類型的方法要么干脆省去 return 語句。對于 void來說,NULL 不是一個(gè)合法的返回值。

      function fun() :void {   echo "hello world"; }

      3. 類常量可見性

      class Something {     const PUBLIC_CONST_A = 1;     public const PUBLIC_CONST_B = 2;     protected const PROTECTED_CONST = 3;     private const PRIVATE_CONST = 4; }

      4. iterable 偽類

      這可以被用在參數(shù)或者返回值類型中,它代表接受數(shù)組或者實(shí)現(xiàn)了Traversable接口的對象.

      function iterator(iterable $iter) {     foreach ($iter as $val) {         //     } }

      5. 多異常捕獲處理

      一個(gè)catch語句塊現(xiàn)在可以通過管道字符(_|_)來實(shí)現(xiàn)多個(gè)異常的捕獲。 這對于需要同時(shí)處理來自不同類的不同異常時(shí)很有用

      try {     // some code } catch (FirstException | SecondException $e) {     // handle first and second exceptions }

      6. list支持鍵名

      $data = [     ["id" => 1, "name" => 'Tom'],     ["id" => 2, "name" => 'Fred'], ];  // list() style list("id" => $id1, "name" => $name1) = $data[0]; var_dump($id1);//1

      7. 字符串支持負(fù)向

      $a= "hello"; $a[-2];//l

      8. 將callback 轉(zhuǎn)閉包

      Closure新增了一個(gè)靜態(tài)方法,用于將callable快速地 轉(zhuǎn)為一個(gè)Closure 對象。

      <?php class Test {     public function exposeFunction()     {         return Closure::fromCallable([$this, 'privateFunction']);     }      private function privateFunction($param)     {         var_dump($param);     } }  $privFunc = (new Test)->exposeFunction(); $privFunc('some value');

      9. http2 服務(wù)推送

      對http2服務(wù)器推送的支持現(xiàn)在已經(jīng)被加入到 CURL 擴(kuò)展

      原文鏈接:https://cloud.tencent.com/dev…

      PHP7.2新特性

      新的對象類型

      這種新的對象類型,object, 引進(jìn)了可用于逆變(contravariant)參數(shù)輸入和協(xié)變(covariant)返回任何對象類型。

      <?php  function test(object $obj) : object {     return new SqlQueue(); }  test(new Stdclass());

      允許重寫抽象方法(Abstract method)

      當(dāng)一個(gè)抽象類繼承于另外一個(gè)抽象類的時(shí)候,繼承后的抽象類可以重寫被繼承的抽象類的抽象方法。

      <?php  abstract class A {     abstract function test(string $s); }  abstract class B extends A {     abstract function test($s) : int; }

      使用Argon2算法生成密碼散列

      Argon2 已經(jīng)被加入到密碼散列(password hashing) API (這些函數(shù)以 password_ 開頭), 以下是暴露出來的常量:

      • PASSWORD_ARGON2I
      • PASSWORD_ARGON2_DEFAULT_MEMORY_COST
      • PASSWORD_ARGON2_DEFAULT_TIME_COST
      • PASSWORD_ARGON2_DEFAULT_THERADS

      允許分組命名空間的尾部逗號

      命名空間可以在PHP 7中使用尾隨逗號進(jìn)行分組引入。

      <?php  use FooBar{     Foo,     Bar,     Baz, };

      PHP7.3新特性

      1 發(fā)布時(shí)間

      06 Dec 2018

      官網(wǎng)PHP7.3新特性

      2 更靈活的HeredocNowdoc語法

      結(jié)束標(biāo)記不再需要獨(dú)立一行或緊跟分號了。同時(shí)結(jié)束標(biāo)記也可以使用縮進(jìn),使用縮進(jìn)時(shí)doc內(nèi)容的每行都會(huì)跳過相應(yīng)的縮進(jìn)。

      $data = ["元素", <<<STR     Doc Content     The new line     STR, 42,]; var_dump($data);  array(3) {   [0]=>   string(6) "元素"   [1]=>   string(25) "Doc Content The new line"   [2]=>   int(42) }

      以上語法中,Heredoc 作為一個(gè)數(shù)組元素出現(xiàn),同時(shí)結(jié)束標(biāo)記沒有獨(dú)立在一行,還有縮進(jìn)。注意定義的字符串內(nèi)容,兩行的縮進(jìn)都被剝除了。

      3 數(shù)組析構(gòu)支持引用賦值

      演示:

      $v = [10, 20]; [$a, &$b] = $v; $b += 10; var_dump($v, $a, $b);  array(2) {   [0]=>   int(10)   [1]=>   &int(30) } int(10) int(30)

      在為 $b 解析時(shí),使用了引用傳遞,此時(shí) $b 和 $v[1] 元素保持引用關(guān)系。

      4 list結(jié)構(gòu)支持引用解析。

      演示:

      $v = [10, 20]; list($c, &$d) = $v; $d += 10; var_dump($v, $c, $d);  array(2) {   [0]=>   int(10)   [1]=>   &int(30) } int(10) int(30)

      5 instanceof 運(yùn)算符支持字面量語法

      instanceof 的第一個(gè)運(yùn)算數(shù)支持字面量,非對象型字面量檢測的結(jié)果為 false。

      var_dump("literal" instanceof stdClass); var_dump(42 instanceof stdClass); var_dump(new stdClass() instanceof stdClass);  bool(false) bool(false) bool(true)

      6 支持調(diào)用時(shí)參數(shù)的尾隨逗號

      調(diào)用函數(shù)時(shí),參數(shù)列表后允許跟隨一個(gè)逗號。

      function methodName($p1, $p2) {     // some statmenet     var_dump($p1, $p2); } methodName(10, 20, );  int(10) int(20)

      調(diào)用函數(shù)時(shí),第二個(gè)(最后一個(gè))參數(shù)后,增加了一個(gè)逗號是允許的。但定義是不行。

      7 BC 數(shù)學(xué)函數(shù)

      bcscale()函數(shù)支持獲取當(dāng)前BC函數(shù)所使用的 scale。

      bcscale(3); var_dump(bcscale());  int(3)

      8 LDAP 全支持

      LDAP:Lightweight Directory Access Protocol,輕量目錄訪問協(xié)議完全支持。

      9 多字節(jié)字符串函數(shù)更新

      • 全功能的 Case-Mapping 和 Case-Folding 支持
      • 大小寫不敏感字符串運(yùn)算符使用 Case-Folding
      • 支持 Unicode 11
      • 長字符串支持
      • 命名捕獲支持

      10 FastCGI 進(jìn)程管理

      增加了如下的選項(xiàng)來配置FPM的Logging:(暫未翻譯)

      • log_limit
      • log_buffering
      • decorate_workers_output

      11 Argon2id 算法支持

      –with-password-argon2[=dir] 配置參數(shù)后。提供了對Password_*()函數(shù)中的 Argon2i 和 Argon2id 散列的支持。使用 PASSWORD_ARGON2ID 常量進(jìn)行指定算法。PHP需要 libargon2 庫版本要大于(等于)20161029。

      12 CompileError 異常替代了一些編譯錯(cuò)誤

      新的 CompileError 異常被添加,ParseError繼承了這個(gè)異常。目前只會(huì)影響 Token_GET_All() 在 Token_parse 模式下可能引發(fā)的編譯錯(cuò)誤。

      13 性能提升

      據(jù)說 PHP7.3 比 PHP 7.0 快 22%。未測試,有機(jī)會(huì)壓測一下。

      14 廢棄大小寫不敏感的常量

      大小寫不敏感的常量聲明現(xiàn)已被廢棄。將 TRUE 作為第三個(gè)參數(shù)傳遞給 define() 會(huì)導(dǎo)致一個(gè)廢棄警告。大小寫不敏感的使用(在讀取時(shí)使用一個(gè)與聲明時(shí)不同的大小寫方式)也已被廢棄。

      15 廢棄在字符串中搜索非字符串內(nèi)容

      將一個(gè)非字符串內(nèi)容傳遞給字符串搜索函數(shù)。 在將來所有待搜索的內(nèi)容都將被視為字符串,而不是 ASCII 編碼值。如果需要依賴這個(gè)特性,你應(yīng)該 要么顯示地進(jìn)行類型轉(zhuǎn)換(轉(zhuǎn)為字符串),或者顯示地調(diào)用 chr()。 以下是受到影響的方法:

      16 新常量

      新常量

      原文鏈接:https://zhuanlan.zhihu.com/p/…

      PHP7.4新特性

      1、預(yù)加載

      預(yù)加載功能是指在服務(wù)啟動(dòng)時(shí),未運(yùn)行任何應(yīng)用程序代碼之前,將一組PHP文件加載到內(nèi)存中,甚至可以對框架進(jìn)行預(yù)加載,以提高性能。如果對預(yù)加載代碼進(jìn)行修改,需要重啟服務(wù)。

      預(yù)加載相比opcache:opcache雖然解決了重復(fù)編譯問題,但opcache本身也有開銷。引用Dmitry Stogov大佬的話:

      Not only. The idea is to completely eliminate compilation and opcache overhead (copying from SHM to process memory and insertions into function/class tables on each request). Using this technique, we might write standard functions and classes in PHP (similar to systemlib.php in HHVM).
      預(yù)加載是完全消除編譯和opcache所帶來的開銷(從共享內(nèi)存復(fù)制到進(jìn)程內(nèi)存,并在每個(gè)請求上插入到function/class表中),使用這種技術(shù)可以在PHP中編寫標(biāo)準(zhǔn)函數(shù)和類(類似于HHVM中的systemlib.php)

      想想看,其實(shí)預(yù)加載主要是提升像php-fpm這種架構(gòu)形式的性能,并且會(huì)占用

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號