如果 Opcache 被停用,此函數會返回 false。
(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL ZendOpcache > 7.0.2)
opcache_get_status — 取得快取的狀態資訊
include_scripts
包含特定腳本的狀態資訊
返回一個包含資訊的陣列,可選擇性地包含特定腳本的狀態資訊,或者在失敗時返回 false
。
如果使用了 opcache.restrict_api
且目前路徑違反了規則,則會引發 E_WARNING 錯誤;不會返回任何狀態資訊。
版本 | 說明 |
---|---|
PHP 8.3.0 |
opcache_get_status()['scripts'][n]['revalidate'] 現在包含一個 Unix 時間戳記,表示腳本時間戳記的下一次重新驗證到期時間,由 opcache.revalidate_freq INI 指令決定。 |
範例 #1 opcache_get_status() 範例
<?php
var_dump(opcache_get_status());
?>
上述範例將輸出類似以下的內容
array(9) { 'opcache_enabled' => bool(true) 'cache_full' => bool(false) 'restart_pending' => bool(false) 'restart_in_progress' => bool(false) 'memory_usage' => array(4) { 'used_memory' => int(9167936) 'free_memory' => int(125049792) 'wasted_memory' => int(0) 'current_wasted_percentage' => double(0) } 'interned_strings_usage' => array(4) { 'buffer_size' => int(8388608) 'used_memory' => int(2593616) 'free_memory' => int(5794992) 'number_of_strings' => int(10358) } 'opcache_statistics' => array(13) { 'num_cached_scripts' => int(0) 'num_cached_keys' => int(0) 'max_cached_keys' => int(16229) 'hits' => int(0) 'start_time' => int(1733310010) 'last_restart_time' => int(0) 'oom_restarts' => int(0) 'hash_restarts' => int(0) 'manual_restarts' => int(0) 'misses' => int(0) 'blacklist_misses' => int(0) 'blacklist_miss_ratio' => double(0) 'opcache_hit_rate' => double(0) } 'scripts' => array(0) { } 'jit' => array(7) { 'enabled' => bool(false) 'on' => bool(false) 'kind' => int(5) 'opt_level' => int(4) 'opt_flags' => int(6) 'buffer_size' => int(0) 'buffer_free' => int(0) } }