PHP 8.0正式發佈:支持JIT編譯器,性能提升高達3倍

{"type":"doc","content":[{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"美國時間11月26日,PHP團隊宣佈PHP 8.0正式GA。PHP 8.0是PHP語言的最新主要版本,帶來了許多新特性和優化,包括命名參數(named arguments)、聯合類型(union types)、屬性(attributes)、構造器屬性提升(constructor property promotion)、Match表達式、nullsafe運算符、JIT,以及針對類型系統、錯誤處理和一致性的諸多改進。"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" "}]},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/04\/88\/04f7766238ee3cfdf003da32eb898688.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"PHP 8.0.0 下載地址:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/www.php.net\/downloads","title":"","type":null},"content":[{"type":"text","text":"https:\/\/www.php.net\/downloads"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下文將對新版本的重要亮點做簡單介紹:"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"命名參數"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/named_params","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/named_params"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"htmlspecialchars($string, double_encode: false);"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"僅指定必需參數,跳過可選參數。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"參數與順序無關,且是自描述的。"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"屬性"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"現在,開發者可以使用基於PHP原生語法的結構化元數據來代替PHPDoc註解。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/attributes_v2","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/attributes_v2"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class PostsController\n{\n \/**\n * @Route(\"\/api\/posts\/{id}\", methods={\"GET\"})\n *\/\n public function get($id) { \/* ... *\/ }\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class PostsController\n{\n #[Route(\"\/api\/posts\/{id}\", methods: [\"GET\"])]\n public function get($id) { \/* ... *\/ }\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"構造器屬性提升"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"新版本定義和初始化屬性所用的樣板代碼更少。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/constructor_promotion","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/constructor_promotion"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class Point {\n public float $x;\n public float $y;\n public float $z;\n\n\n public function __construct(\n float $x = 0.0,\n float $y = 0.0,\n float $z = 0.0,\n ) {\n $this->x = $x;\n $this->y = $y;\n $this->z = $z;\n }\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class Point {\n public function __construct(\n public float $x = 0.0,\n public float $y = 0.0,\n public float $z = 0.0,\n ) {}\n}"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"聯合類型"},{"type":"text","text":"(Union Types)"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Union Types 支持接收多個不同類型的值,而不是單個類型。目前PHP已經支持兩種特殊的聯合類型:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Type或null,使用特殊?Type語法。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"array或Traversable,使用特殊iterable類型。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於類型組合,可以使用在運行時經過驗證的原生聯合類型聲明來代替PHPDoc註解。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/union_types_v2","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/union_types_v2"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"支持聯合類型之後,將會允許將更多類型信息從 phpdoc 遷移至函數簽名。可以說,泛型之後,聯合類型是目前類型聲明系統中最大的突破口。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class Number {\n \/** @var int|float *\/\n private $number;\n\n\n \/**\n * @param float|int $number\n *\/\n public function __construct($number) {\n $this->number = $number;\n }\n}\n\n\nnew Number('NaN'); \/\/ O"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class Number {\n public function __construct(\n private int|float $number\n ) {}\n}\n\n\nnew Number('NaN'); \/\/ TypeError"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Match表達式"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"新的match很像switch,並具有以下特性:"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Match是一個表達式,表示其結果可以存儲在變量中或返回。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Match分支僅支持單行表達式,不需要break; 語句。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Match執行嚴格比較。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/match_expression_v2","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/match_expression_v2"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"switch (8.0) {\n case '8.0':\n $result = \"Oh no!\";\n break;\n case 8.0:\n $result = \"This is what I expected\";\n break;\n}\necho $result;\n\/\/> Oh no!"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"echo match (8.0) {\n '8.0' => \"Oh no!\",\n 8.0 => \"This is what I expected\",\n};\n\/\/> This is what I expected"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Nullsafe運算符"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"現在,開發者可以使用帶有新的nullsafe運算符的調用鏈來代替null check。當對鏈中一個元素的求值失敗時,整個鏈的執行將中止,並且整個鏈的求值爲null。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/nullsafe_operator","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/nullsafe_operator"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"$country = null;\n\n\nif ($session !== null) {\n $user = $session->user;\n\n\n if ($user !== null) {\n $address = $user->getAddress();\n\n\n if ($address !== null) {\n $country = $address->country;\n }\n }"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"$country = $session?->user?->getAddress()?->country;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"字符串與數字的判斷更合理"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用==和其他非嚴格比較運算符對字符串和數字之間做比較時,原本的做法是將字符串強制轉換爲數字,然後對整數或浮點數進行比較。這會導致許多令人驚訝的比較結果,其中最值得注意的是 "},{"type":"codeinline","content":[{"type":"text","text":"0 == \"foobar\""}]},{"type":"text","text":" 返回true。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在新版本中,僅在字符串實際爲數字時才使用數字比較,否則將數字轉換爲字符串,並執行字符串比較。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/string_to_number_comparison","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/string_to_number_comparison"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"0 == 'foobar' \/\/ true"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"0 == 'foobar' \/\/ false"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"內部函數的類型錯誤一致"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在新版本中,如果參數驗證失敗,大多數內部函數將拋出Error異常。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/consistent_type_errors","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/consistent_type_errors"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"strlen([]); \/\/ Warning: strlen() expects parameter 1 to be string, array given\n\n\narray_chunk([], -1); \/\/ Warning: array_chunk(): Size parameter expected to be greater than 0"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"strlen([]); \/\/ TypeError: strlen(): Argument #1 ($str) must be of type string, array given\n\n\narray_chunk([], -1); \/\/ ValueError: array_chunk(): Argument #2 ($length) must be greater than 0"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"JIT編譯"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"PHP 8引入了兩個JIT編譯引擎。Tracing JIT的表現最出色,它在綜合基準測試中的性能提高到大約3倍,在某些特定的傳統應用程序中提高到1.5–2倍。典型的應用程序性能與PHP 7.4相當。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"JIT對PHP 8性能的貢獻"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/9b\/fd\/9b2b17435f130bb02fddf1c67603eafd.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"類型系統和錯誤處理方面的改進"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對算術\/按位運算符進行更嚴格的類型檢查("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/arithmetic_operator_type_checks","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/arithmetic_operator_type_checks"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"抽象特徵方法驗證("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/abstract_trait_method_validation","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/abstract_trait_method_validation"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"魔術方法的正確簽名("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/magic-methods-signature","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/magic-methods-signature"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"重分類引擎警告("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/engine_warnings","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/engine_warnings"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不兼容方法簽名的致命錯誤("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/lsp_errors","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/lsp_errors"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"@運算符不再使致命錯誤靜默。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用私有方法繼承("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/inheritance_private_methods","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/inheritance_private_methods"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"混合類型("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/mixed_type_v2","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/mixed_type_v2"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"靜態返回類型("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/static_return_type","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/static_return_type"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"內部函數類型("},{"type":"link","attrs":{"href":"https:\/\/externals.io\/message\/106522","title":"","type":null},"content":[{"type":"text","text":"https:\/\/externals.io\/message\/106522"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不透明的對象代替Curl、Gd、Sockets、OpenSSL、XMLWriter和XML擴展的資源"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"其他語法調整和改進"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在參數列表("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/trailing_comma_in_parameter_list","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/trailing_comma_in_parameter_list"}]},{"type":"text","text":")和使用閉包的列表("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/trailing_comma_in_closure_use_list","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/trailing_comma_in_closure_use_list"}]},{"type":"text","text":")中允許結尾逗號"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"non-capturing捕獲("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/non-capturing_catches","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/non-capturing_catches"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"變量語法調整("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/variable_syntax_tweaks","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/variable_syntax_tweaks"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"將命名空間名稱視爲單個令牌("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/namespaced_names_as_token","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/namespaced_names_as_token"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Throw現在是表達式("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/throw_expression","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/throw_expression"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在對象上允許::class("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/class_name_literal_on_object","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/class_name_literal_on_object"}]},{"type":"text","text":")"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"新的類、接口和函數"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Weak Map類("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/weak_maps","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/weak_maps"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Stringable接口("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/stringable","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/stringable"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"str_contains()、str_starts_with()、str_ends_with()("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/str_contains","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/str_contains"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"fdiv()("},{"type":"link","attrs":{"href":"https:\/\/github.com\/php\/php-src\/pull\/4769","title":"","type":null},"content":[{"type":"text","text":"https:\/\/github.com\/php\/php-src\/pull\/4769"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"get_debug_type()("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/get_debug_type","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/get_debug_type"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"get_resource_id()("},{"type":"link","attrs":{"href":"https:\/\/github.com\/php\/php-src\/pull\/5427","title":"","type":null},"content":[{"type":"text","text":"https:\/\/github.com\/php\/php-src\/pull\/5427"}]},{"type":"text","text":"0"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"token_get_all()對象實現("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/token_as_object","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/token_as_object"}]},{"type":"text","text":")"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"下載"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"要下載PHP 8的源代碼,請訪問下載頁面("},{"type":"link","attrs":{"href":"https:\/\/www.php.net\/downloads","title":"","type":null},"content":[{"type":"text","text":"https:\/\/www.php.net\/downloads"}]},{"type":"text","text":")。Windows二進制文件位於Windows版PHP網站("},{"type":"link","attrs":{"href":"http:\/\/windows.php.net\/download","title":"","type":null},"content":[{"type":"text","text":"http:\/\/windows.php.net\/download"}]},{"type":"text","text":")。更改列表位於ChangeLog("},{"type":"link","attrs":{"href":"http:\/\/www.php.net\/ChangeLog-8.php","title":"","type":null},"content":[{"type":"text","text":"http:\/\/www.php.net\/ChangeLog-8.php"}]},{"type":"text","text":")。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"PHP手冊中提供了遷移指南("},{"type":"link","attrs":{"href":"https:\/\/www.php.net\/manual\/en\/migration80.php","title":"","type":null},"content":[{"type":"text","text":"https:\/\/www.php.net\/manual\/en\/migration80.php"}]},{"type":"text","text":")。請查閱它以獲取新特性細節和向後不兼容更改的詳細列表。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"原文鏈接:"},{"type":"link","attrs":{"href":"https:\/\/www.php.net\/releases\/8.0\/en.php","title":"","type":null},"content":[{"type":"text","text":"https:\/\/www.php.net\/releases\/8.0\/en.php"}]}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章