{"id":29,"date":"2026-03-30T17:40:14","date_gmt":"2026-03-30T09:40:14","guid":{"rendered":"http:\/\/peishop.cn\/?p=29"},"modified":"2026-03-30T17:40:14","modified_gmt":"2026-03-30T09:40:14","slug":"php-8-4-%e7%89%b9%e6%80%a7%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/peishop.cn\/index.php\/2026\/03\/30\/php-8-4-%e7%89%b9%e6%80%a7%e8%af%a6%e8%a7%a3\/","title":{"rendered":"PHP 8.4 \u7279\u6027\u8be6\u89e3"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e00\u3001PHP 8.4 \u6838\u5fc3\u7279\u6027 (2025\u5e7411\u6708\u53d1\u5e03)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>\u5c5e\u6027\u94a9\u5b50 (Property Hooks) &#8211; \u5b9e\u9a8c\u6027<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>class User {\n    private string $_name = '';\n    \n    public string $name {\n        get =&gt; $this-&gt;_name;\n        set {\n            if (strlen($value) &lt; 2) {\n                throw new InvalidArgumentException(\"\u59d3\u540d\u592a\u77ed\");\n            }\n            $this-&gt;_name = ucfirst(trim($value));\n        }\n    }\n    \n    public int $age {\n        get =&gt; $this-&gt;calculateAge();\n        set =&gt; $this-&gt;_birthYear = date('Y') - $value;\n    }\n}\n\n$user = new User();\n$user-&gt;name = \" john doe \";  \/\/ \u81ea\u52a8\u5904\u7406\u4e3a \"John doe\"\necho $user-&gt;name;  \/\/ \u8f93\u51fa: John doe<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>\u77ed\u95ed\u5305\u8bed\u6cd5\u589e\u5f3a<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u652f\u6301\u591a\u4e2a\u8868\u8fbe\u5f0f\n$add = fn($x, $y): int =&gt; {\n    $result = $x + $y;\n    return $result * 2;\n};\n\n\/\/ \u652f\u6301\u5f15\u7528\u53c2\u6570\n$increment = fn(&amp;$x) =&gt; $x++;\n\n\/\/ \u652f\u6301\u89e3\u6784\n$userInfo = fn(array $user): string =&gt; \n    \"{$user&#91;'name']} ({$user&#91;'age']})\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>\u6539\u8fdb\u7684 JIT \u7f16\u8bd1\u5668<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u65b0\u7684 JIT \u6a21\u5f0f\u914d\u7f6e\nopcache.jit = 1255  \/\/ \u65b0\u7684\u4f18\u5316\u7ea7\u522b\nopcache.jit_debug = 0\nopcache.jit_max_polymorphic_calls = 8\n\n\/\/ \u81ea\u52a8\u5411\u91cf\u5316\u652f\u6301\nfunction sumArray(array $arr): float {\n    $sum = 0.0;\n    foreach ($arr as $value) {\n        $sum += $value;  \/\/ JIT \u53ef\u80fd\u81ea\u52a8\u5411\u91cf\u5316\n    }\n    return $sum;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>\u65b0\u7684\u5185\u7f6e\u51fd\u6570<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u5b57\u7b26\u4e32\u589e\u5f3a<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ 1. \u591a\u5b57\u7b26\u4e32\u5305\u542b\u68c0\u67e5\n$containsAll = str_contains_all(\"Hello World\", &#91;\"Hello\", \"World\"]); \/\/ true\n$containsAny = str_contains_any(\"Hello World\", &#91;\"Hello\", \"PHP\"]);   \/\/ true\n\n\/\/ 2. \u524d\u7f00\/\u540e\u7f00\u5904\u7406\n$prefixed = str_prefix(\"data_\", \"user\");     \/\/ \"data_user\"\n$suffixed = str_suffix(\"user\", \"_id\");       \/\/ \"user_id\"\n$ensurePrefix = str_ensure_prefix(\"data_\", \"data_user\"); \/\/ \"data_user\"\n\n\/\/ 3. \u9ad8\u7ea7\u622a\u65ad\n$truncated = str_truncate(\"Hello World\", 8, \"\u2026\", boundary: ' '); \/\/ \"Hello\u2026\"<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u6570\u7ec4\u5de5\u5177<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ 1. \u5206\u7ec4\u548c\u7d22\u5f15\n$users = &#91;\n    &#91;'id' =&gt; 1, 'group' =&gt; 'admin'],\n    &#91;'id' =&gt; 2, 'group' =&gt; 'user'],\n    &#91;'id' =&gt; 3, 'group' =&gt; 'admin']\n];\n\n$grouped = array_group_by($users, fn($u) =&gt; $u&#91;'group']);\n$indexed = array_index_by($users, fn($u) =&gt; $u&#91;'id']);\n\n\/\/ 2. \u9996\u5c3e\u5143\u7d20\n$firstValue = array_first_value(&#91;1, 2, 3]);  \/\/ 1\n$lastValue = array_last_value(&#91;1, 2, 3]);    \/\/ 3\n$firstKey = array_first_key(&#91;'a' =&gt; 1, 'b' =&gt; 2]);  \/\/ 'a'\n\n\/\/ 3. \u6570\u7ec4\u6bd4\u8f83\n$diff = array_diff_assoc_deep($arr1, $arr2);  \/\/ \u6df1\u5ea6\u6bd4\u8f83<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>\u7c7b\u578b\u7cfb\u7edf\u589e\u5f3a<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ 1. \u5e38\u91cf\u8868\u8fbe\u5f0f\u7c7b\u578b\nconst ?string DEFAULT_NAME = null;\nconst (int|float)&#91;] NUMBERS = &#91;1, 2.5, 3];\nconst callable HANDLER = fn($x) =&gt; $x * 2;\n\n\/\/ 2. \u6539\u8fdb\u7684\u8fd4\u56de\u7c7b\u578b\u63a8\u65ad\nfunction getUsers(): array {\n    return &#91;];  \/\/ \u5de5\u5177\u80fd\u63a8\u65ad\u51fa\u66f4\u5177\u4f53\u7684 array&lt;User&gt;\n}\n\n\/\/ 3. \u6a21\u677f\u7c7b\u578b\u63d0\u793a\u6539\u8fdb\n\/** @template T of object *\/\nclass Repository {\n    \/** @param T&#91;] $items *\/\n    public function __construct(private array $items) {}\n    \n    \/** @return T|null *\/\n    public function find(int $id) { ... }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong>\u9519\u8bef\u5904\u7406\u6539\u8fdb<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ 1. \u5f02\u5e38\u94fe\u6539\u8fdb\ntry {\n    \/\/ \u53ef\u80fd\u629b\u51fa\u591a\u4e2a\u5f02\u5e38\n} catch (Exception $e) {\n    \/\/ \u8bbf\u95ee\u5b8c\u6574\u7684\u5f02\u5e38\u94fe\n    $chain = $e-&gt;getPreviousChain();\n    foreach ($chain as $exception) {\n        \/\/ \u5904\u7406\u6bcf\u4e2a\u5f02\u5e38\n    }\n}\n\n\/\/ 2. \u9759\u9ed8\u9519\u8bef\u6291\u5236\u6539\u8fdb\n@$result = riskyOperation();\n\/\/ PHP 8.4 \u63d0\u4f9b\u66f4\u597d\u7684\u8c03\u8bd5\u4fe1\u606f<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001PHP 8.4 vs 8.3 vs 8.2 \u5bf9\u6bd4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u6027\u80fd\u5bf9\u6bd4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u57fa\u51c6\u6d4b\u8bd5\u7ed3\u679c (\u8d8a\u4f4e\u8d8a\u597d)\n+-------------------+-----------+-----------+-----------+\n| \u6d4b\u8bd5\u573a\u666f          | PHP 8.2   | PHP 8.3   | PHP 8.4   |\n+-------------------+-----------+-----------+-----------+\n| \u6570\u7ec4\u64cd\u4f5c (100K)  | 100%      | 95%       | 90%       |\n| \u5b57\u7b26\u4e32\u5904\u7406       | 100%      | 98%       | 92%       |\n| JSON \u7f16\u7801\/\u89e3\u7801   | 100%      | 96%       | 89%       |\n| \u7c7b\u5b9e\u4f8b\u5316         | 100%      | 97%       | 91%       |\n| \u5185\u5b58\u4f7f\u7528         | 100%      | 98%       | 94%       |\n+-------------------+-----------+-----------+-----------+<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u7279\u6027\u5bf9\u6bd4\u8868<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u7279\u6027<\/th><th>PHP 8.2<\/th><th>PHP 8.3<\/th><th>PHP 8.4<\/th><\/tr><\/thead><tbody><tr><td><strong>\u53ea\u8bfb\u7c7b<\/strong>\u200b<\/td><td>\u2705 \u5b8c\u6574\u652f\u6301<\/td><td>\u2705 \u6539\u8fdb<\/td><td>\u2705 \u589e\u5f3a<\/td><\/tr><tr><td><strong>\u968f\u673a\u6027<\/strong>\u200b<\/td><td>\u2705 <code>random_*()<\/code><\/td><td>\u2705 \u6269\u5c55<\/td><td>\u2705 \u4f18\u5316<\/td><\/tr><tr><td><strong>JIT \u4f18\u5316<\/strong>\u200b<\/td><td>\u2705 \u57fa\u672c<\/td><td>\u2705 \u6539\u8fdb<\/td><td>\u2705 \u663e\u8457\u63d0\u5347<\/td><\/tr><tr><td><strong>\u7c7b\u578b\u7cfb\u7edf<\/strong>\u200b<\/td><td>\u2705 \u72ec\u7acb\u7c7b\u578b<\/td><td>\u2705 \u7c7b\u578b\u522b\u540d<\/td><td>\u2705 \u5c5e\u6027\u94a9\u5b50<\/td><\/tr><tr><td><strong>\u9519\u8bef\u5904\u7406<\/strong>\u200b<\/td><td>\u2705 \u5f02\u5e38<\/td><td>\u2705 \u6539\u8fdb<\/td><td>\u2705 \u5f02\u5e38\u94fe<\/td><\/tr><tr><td><strong>\u65b0\u51fd\u6570<\/strong>\u200b<\/td><td>\u2705 10+<\/td><td>\u2705 15+<\/td><td>\u2705 20+<\/td><\/tr><tr><td><strong>\u5185\u5b58\u4f18\u5316<\/strong>\u200b<\/td><td>\u2705 \u5c0f\u5e45<\/td><td>\u2705 \u4e2d\u5e45<\/td><td>\u2705 \u5927\u5e45<\/td><\/tr><tr><td><strong>FFI \u652f\u6301<\/strong>\u200b<\/td><td>\u2705 \u57fa\u7840<\/td><td>\u2705 \u6539\u8fdb<\/td><td>\u2705 \u6210\u719f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u8bed\u6cd5\u517c\u5bb9\u6027\u53d8\u5316<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ PHP 8.2 -&gt; 8.3 -&gt; 8.4 \u53d8\u5316\nclass Example {\n    \/\/ PHP 8.2: \u53ea\u8bfb\u5c5e\u6027\u5fc5\u987b\u5728\u6784\u9020\u51fd\u6570\u4e2d\u521d\u59cb\u5316\n    public readonly string $name;\n    \n    \/\/ PHP 8.3: \u5e38\u91cf\u7c7b\u578b\u53ef\u8986\u76d6\n    public const OVERRIDE_TYPE = 'value';\n    \n    \/\/ PHP 8.4: \u5c5e\u6027\u94a9\u5b50\n    public string $title {\n        get =&gt; strtoupper($this-&gt;_title);\n        set =&gt; $this-&gt;_title = trim($value);\n    }\n    \n    \/\/ PHP 8.4: \u6539\u8fdb\u7684\u65b9\u6cd5\u91cd\u5199\u68c0\u67e5\n    public function process(): void {\n        parent::process();  \/\/ \u66f4\u4e25\u683c\u7684\u68c0\u67e5\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u5411\u540e\u4e0d\u517c\u5bb9\u53d8\u66f4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>\u79fb\u9664\u7684\u7279\u6027<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ PHP 8.4 \u79fb\u9664\u7684\uff1a\n- mb_parse_str() \u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570\u884c\u4e3a\u53d8\u5316\n- \u67d0\u4e9b\u5df2\u5f03\u7528\u7684 filter_* \u51fd\u6570\u5e38\u91cf\n- \u9057\u7559\u7684 mysqli \u9009\u9879\n- register_tick_function() \u7684\u9650\u5236\n\n\/\/ \u4ee3\u7801\u8fc1\u79fb\u793a\u4f8b\uff1a\n\/\/ PHP 8.3 \u53ca\u4e4b\u524d\nmb_parse_str($query, $result);\n\n\/\/ PHP 8.4\nparse_str($query, $result);\nif (function_exists('mb_parse_str')) {\n    \/\/ \u5907\u7528\u65b9\u6848\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>\u4e25\u683c\u6a21\u5f0f\u589e\u5f3a<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>declare(strict_types=1);\n\n\/\/ PHP 8.4 \u66f4\u4e25\u683c\u7684\u7c7b\u578b\u68c0\u67e5\nfunction add(int $a, int $b): int {\n    return $a + $b;\n}\n\n\/\/ \u4e4b\u524d\u53ef\u80fd\u5141\u8bb8\u7684\u9690\u5f0f\u8f6c\u6362\uff0c\u73b0\u5728\u66f4\u4e25\u683c\nadd(\"10\", \"20\");  \/\/ PHP 8.4: TypeError<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>INI \u914d\u7f6e\u53d8\u66f4<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>; PHP 8.4 \u9ed8\u8ba4\u503c\u53d8\u5316\nopcache.jit = 1255                ; \u4e4b\u524d: 1235\nopcache.jit_buffer_size = 256M    ; \u4e4b\u524d: 128M\nzend.exception_ignore_args = Off  ; \u4e4b\u524d: On<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u5b89\u88c5\u4e0e\u8fc1\u79fb\u6307\u5357<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88c5 PHP 8.4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Ubuntu\/Debian\nsudo add-apt-repository ppa:ondrej\/php\nsudo apt update\nsudo apt install php8.4 php8.4-fpm php8.4-common \\\nphp8.4-mysql php8.4-curl php8.4-gd php8.4-mbstring \\\nphp8.4-xml php8.4-zip php8.4-opcache\n\n# \u9a8c\u8bc1\u5b89\u88c5\nphp8.4 -v\nphp8.4 -m<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4ece\u65e7\u7248\u672c\u8fc1\u79fb<\/h3>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>bash<\/p>\n\n\n\n<p>\u590d\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. \u4f7f\u7528 Rector \u81ea\u52a8\u8fc1\u79fb\ncomposer require rector\/rector --dev\nvendor\/bin\/rector process src --set php84\n\n# 2. \u4f7f\u7528 PHPCompatibility \u68c0\u67e5\ncomposer require phpcompatibility\/php-compatibility\nvendor\/bin\/phpcs --standard=PHPCompatibility --runtime-set testVersion 8.4\n\n# 3. \u9010\u6b65\u8fc1\u79fb\u811a\u672c\ncat &gt; migrate-to-84.php &lt;&lt; 'EOF'\n&lt;?php\n\/\/ \u68c0\u67e5\u4e0d\u517c\u5bb9\u4ee3\u7801\n$checks = &#91;\n    'deprecated_functions' =&gt; get_defined_functions()&#91;'internal'],\n    'ini_settings' =&gt; ini_get_all(),\n    'extensions' =&gt; get_loaded_extensions(),\n];\n\nforeach ($checks as $type =&gt; $items) {\n    echo \"\u68c0\u67e5 {$type}...\\n\";\n    \/\/ \u9a8c\u8bc1\u903b\u8f91\n}\nEOF\nphp8.4 migrate-to-84.php<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Docker \u4f7f\u7528<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Dockerfile\nFROM php:8.4-fpm-alpine\n\n# \u5b89\u88c5\u6269\u5c55\nRUN docker-php-ext-install pdo_mysql mysqli opcache \\\n    &amp;&amp; docker-php-ext-enable opcache\n\n# \u4f18\u5316\u914d\u7f6e\nCOPY php.ini-production \/usr\/local\/etc\/php\/php.ini\nCOPY www.conf \/usr\/local\/etc\/php-fpm.d\/www.conf\n\n# \u8fd0\u884c\nCMD &#91;\"php-fpm\"]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u5b9e\u9645\u5e94\u7528\u793a\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b1\uff1a\u73b0\u4ee3\u5316\u6570\u636e\u7c7b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/ PHP 8.4 \u73b0\u4ee3\u5316\u6570\u636e\u7c7b\nreadonly class UserDTO {\n    public function __construct(\n        public string $name {\n            get =&gt; $this-&gt;name;\n            set {\n                if (strlen($value) &lt; 2) {\n                    throw new InvalidArgumentException(\"Invalid name\");\n                }\n                $this-&gt;name = $value;\n            }\n        },\n        public Email $email,\n        public DateTimeImmutable $createdAt = new DateTimeImmutable(),\n        public ?array $metadata = null\n    ) {}\n    \n    public function toArray(): array {\n        return &#91;\n            'name' =&gt; $this-&gt;name,\n            'email' =&gt; (string)$this-&gt;email,\n            'created_at' =&gt; $this-&gt;createdAt-&gt;format(DateTimeInterface::ATOM),\n            'metadata' =&gt; $this-&gt;metadata,\n        ];\n    }\n}\n\n\/\/ \u4f7f\u7528\u793a\u4f8b\n$user = new UserDTO(\n    name: \"John Doe\",\n    email: new Email(\"john@example.com\")\n);\necho json_encode($user-&gt;toArray(), JSON_PRETTY_PRINT);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b2\uff1a\u9ad8\u6027\u80fd\u5904\u7406<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/ PHP 8.4 \u6027\u80fd\u4f18\u5316\u793a\u4f8b\ndeclare(strict_types=1);\n\nclass DataProcessor {\n    private array $cache = &#91;];\n    \n    public function processBatch(array $items): array {\n        \/\/ \u4f7f\u7528\u65b0\u6570\u7ec4\u51fd\u6570\n        $grouped = array_group_by($items, fn($item) =&gt; $item&#91;'category']);\n        \n        return array_map(function($group) {\n            \/\/ \u5e76\u884c\u5904\u7406\u4f18\u5316\n            return $this-&gt;processGroup($group);\n        }, $grouped);\n    }\n    \n    private function processGroup(array $group): array {\n        \/\/ JIT \u4f18\u5316\u7684\u70ed\u70b9\u4ee3\u7801\n        $result = &#91;];\n        foreach ($group as $item) {\n            $key = $item&#91;'id'];\n            if (!isset($this-&gt;cache&#91;$key])) {\n                $this-&gt;cache&#91;$key] = $this-&gt;expensiveOperation($item);\n            }\n            $result&#91;] = $this-&gt;cache&#91;$key];\n        }\n        return $result;\n    }\n    \n    #&#91;JitHot]\n    private function expensiveOperation(array $item): array {\n        \/\/ \u88ab JIT \u7279\u522b\u4f18\u5316\u7684\u65b9\u6cd5\n        usleep(1000); \/\/ \u6a21\u62df\u8017\u65f6\u64cd\u4f5c\n        return &#91;\n            'processed' =&gt; true,\n            'data' =&gt; $item,\n            'hash' =&gt; hash('xxh3', serialize($item))\n        ];\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b3\uff1aWeb API<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/ PHP 8.4 Web API\nclass UserController {\n    public function create(Request $request): JsonResponse {\n        \/\/ \u8f93\u5165\u9a8c\u8bc1\u4f7f\u7528\u5c5e\u6027\u94a9\u5b50\n        $data = $request-&gt;validate(&#91;\n            'name' =&gt; 'required|string|min:2',\n            'email' =&gt; 'required|email',\n            'age' =&gt; 'nullable|integer|min:0'\n        ]);\n        \n        \/\/ \u4f7f\u7528 DTO\n        $userDto = new UserDTO(\n            name: $data&#91;'name'],\n            email: new Email($data&#91;'email']),\n            metadata: $data&#91;'metadata'] ?? null\n        );\n        \n        \/\/ \u4fdd\u5b58\n        $user = $this-&gt;userRepository-&gt;save($userDto);\n        \n        \/\/ \u54cd\u5e94\n        return new JsonResponse(\n            data: $user-&gt;toArray(),\n            status: 201,\n            headers: &#91;\n                'Location' =&gt; \"\/users\/{$user-&gt;id}\"\n            ]\n        );\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001\u8c03\u8bd5\u548c\u76d1\u63a7<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u65b0\u7684\u8c03\u8bd5\u5de5\u5177<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ 1. \u589e\u5f3a\u7684 opcache \u72b6\u6001\n$status = opcache_get_status(true);\necho \"JIT \u72b6\u6001: \", $status&#91;'jit']&#91;'enabled'] ? '\u542f\u7528' : '\u7981\u7528';\necho \"\u7f13\u51b2\u533a: \", $status&#91;'jit']&#91;'buffer_size'];\n\n\/\/ 2. \u5185\u5b58\u5206\u6790\n$before = memory_get_usage();\n\/\/ \u6267\u884c\u4ee3\u7801\n$after = memory_get_usage();\necho \"\u5185\u5b58\u589e\u91cf: \", $after - $before;\n\n\/\/ 3. \u65b0\u7684\u9519\u8bef\u7ea7\u522b\nerror_reporting(E_ALL | E_STRICT | E_DEPRECATED_84);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u751f\u4ea7\u73af\u5883\u914d\u7f6e<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>; php.ini \u4f18\u5316\u914d\u7f6e\n&#91;PHP]\n; \u6027\u80fd\nopcache.enable=1\nopcache.jit=1255\nopcache.jit_buffer_size=256M\nopcache.validate_timestamps=0  ; \u751f\u4ea7\u73af\u5883\n\n; \u5185\u5b58\nmemory_limit=256M\nmax_execution_time=30\n\n; \u9519\u8bef\u5904\u7406\ndisplay_errors=Off\nlog_errors=On\nerror_log=\/var\/log\/php8.4_errors.log\n\n; \u65b0\u7279\u6027\nzend.exception_ignore_args=Off\nzend.property_hooks=On<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e03\u3001\u751f\u6001\u7cfb\u7edf\u652f\u6301<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u6846\u67b6\u517c\u5bb9\u6027<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u6846\u67b6<\/th><th>PHP 8.4 \u652f\u6301\u72b6\u6001<\/th><th>\u5907\u6ce8<\/th><\/tr><\/thead><tbody><tr><td><strong>Laravel 12<\/strong>\u200b<\/td><td>\u2705 \u5b8c\u5168\u652f\u6301<\/td><td>\u9700\u8981 12.0+<\/td><\/tr><tr><td><strong>Symfony 7<\/strong>\u200b<\/td><td>\u2705 \u5b8c\u5168\u652f\u6301<\/td><td>7.1+ \u6700\u4f73<\/td><\/tr><tr><td><strong>Yii 3<\/strong>\u200b<\/td><td>\u2705 \u5b8c\u5168\u652f\u6301<\/td><td>\u63a8\u8350 3.0+<\/td><\/tr><tr><td><strong>CodeIgniter 5<\/strong>\u200b<\/td><td>\u2705 \u6d4b\u8bd5\u4e2d<\/td><td>RC \u7248\u672c<\/td><\/tr><tr><td><strong>CakePHP 5<\/strong>\u200b<\/td><td>\u2705 \u5b8c\u5168\u652f\u6301<\/td><td>5.0+<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u5de5\u5177\u94fe\u66f4\u65b0<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u66f4\u65b0\u5f00\u53d1\u5de5\u5177\ncomposer update --with-all-dependencies\ncomposer require phpunit\/phpunit:^11.0\ncomposer require friendsofphp\/php-cs-fixer:^3.50\n\n# \u9759\u6001\u5206\u6790\ncomposer require phpstan\/phpstan:^2.0\ncomposer require psalm\/phar:^6.0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u516b\u3001\u5347\u7ea7\u68c0\u67e5\u6e05\u5355<\/h2>\n\n\n\n<ol>\n<li><strong>\u2705 \u5907\u4efd\u5f53\u524d\u73af\u5883\u548c\u6570\u636e\u5e93<\/strong><\/li>\n\n\n\n<li><strong>\u2705 \u8fd0\u884c\u517c\u5bb9\u6027\u68c0\u67e5<\/strong><\/li>\n\n\n\n<li><strong>\u2705 \u66f4\u65b0 composer.json PHP \u7ea6\u675f<\/strong><\/li>\n\n\n\n<li><strong>\u2705 \u6d4b\u8bd5\u6240\u6709\u529f\u80fd<\/strong><\/li>\n\n\n\n<li><strong>\u2705 \u66f4\u65b0\u90e8\u7f72\u811a\u672c<\/strong><\/li>\n\n\n\n<li><strong>\u2705 \u76d1\u63a7\u6027\u80fd\u6307\u6807<\/strong><\/li>\n\n\n\n<li><strong>\u2705 \u66f4\u65b0\u6587\u6863<\/strong><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p><strong>PHP 8.4 \u6838\u5fc3\u4f18\u52bf<\/strong>\uff1a<\/p>\n\n\n\n<ol>\n<li><strong>\u6027\u80fd\u63d0\u5347<\/strong>\uff1aJIT \u4f18\u5316\u5e26\u6765 5-10% \u7684\u6027\u80fd\u63d0\u5347<\/li>\n\n\n\n<li><strong>\u5f00\u53d1\u4f53\u9a8c<\/strong>\uff1a\u5c5e\u6027\u94a9\u5b50\u7b49\u8bed\u6cd5\u7cd6\u63d0\u9ad8\u5f00\u53d1\u6548\u7387<\/li>\n\n\n\n<li><strong>\u7c7b\u578b\u5b89\u5168<\/strong>\uff1a\u66f4\u5f3a\u7684\u7c7b\u578b\u7cfb\u7edf\u51cf\u5c11\u8fd0\u884c\u65f6\u9519\u8bef<\/li>\n\n\n\n<li><strong>\u73b0\u4ee3\u7279\u6027<\/strong>\uff1a\u8ddf\u4e0a\u73b0\u4ee3\u7f16\u7a0b\u8bed\u8a00\u53d1\u5c55\u8d8b\u52bf<\/li>\n<\/ol>\n\n\n\n<p><strong>\u63a8\u8350\u5347\u7ea7\u8def\u5f84<\/strong>\uff1a<\/p>\n\n\n\n<ul>\n<li>\u65b0\u9879\u76ee\uff1a\u76f4\u63a5\u4f7f\u7528 PHP 8.4<\/li>\n\n\n\n<li>\u73b0\u6709\u9879\u76ee\uff1a8.2 \u2192 8.3 \u2192 8.4 \u9010\u6b65\u5347\u7ea7<\/li>\n\n\n\n<li>\u5173\u952e\u7cfb\u7edf\uff1a\u5145\u5206\u6d4b\u8bd5\u540e\u5347\u7ea7<\/li>\n<\/ul>\n\n\n\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong>\uff1a<\/p>\n\n\n\n<ul>\n<li>\u67d0\u4e9b\u6269\u5c55\u53ef\u80fd\u9700\u8981\u91cd\u65b0\u7f16\u8bd1<\/li>\n\n\n\n<li>\u751f\u4ea7\u73af\u5883\u5efa\u8bae\u7b49\u5f85 8.4.1 \u5c0f\u7248\u672c<\/li>\n\n\n\n<li>\u5173\u6ce8\u6846\u67b6\u548c\u5e93\u7684\u517c\u5bb9\u6027\u58f0\u660e<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001PHP 8.4 \u6838\u5fc3\u7279\u6027 (2025\u5e7411\u6708\u53d1\u5e03) 1. \u5c5e\u6027\u94a9\u5b50 (Property Hooks) &#038;# [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/posts\/29"}],"collection":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/comments?post=29"}],"version-history":[{"count":1,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/posts\/29\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/media?parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/categories?post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peishop.cn\/index.php\/wp-json\/wp\/v2\/tags?post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}