©
이 문서에서는 PHP 중국어 웹사이트 매뉴얼 풀어 주다
(PHP 5 >= 5.5.0, PECL ZendOpcache >= 7.0.0)
opcache_reset — 重置字节码缓存的内容
该函数将重置整个字节码缓存。 在调用 opcache_reset() 之后,所有的脚本将会重新载入并且在下次被点击的时候重新解析。
此函数没有参数。
如果字节码缓存被重置成功,则返回 TRUE
;如果字节码缓存被禁用,则返回 FALSE
。
[#1] Anonymous [2015-09-08 15:36:41]
It should be mentioned that opcache_reset() does not reset cache when executed via cli.
So `php -r "var_dump(opcache_reset());"` outputs "true" but doesn't clean cache. Make file, access it via http - and cache is clean.
[#2] antoine dot vdsk at gmail dot com [2015-07-29 17:08:03]
For people who have difficulties with constants and opcache_reset().
If you include a file with constant and do an opcache_reset() in the same file, you'll probably have some error like :
"Notice: Constant already defined"
The trick is to call opcache_reset() in an isolated file, then include another file that include the file with constants.
File a.php
<?php
opcache_reset();
include 'b.php'
?>
File b.php
<?php
include 'constants.php';
?>
File constants.php
<?php
define('MY_CONST', 'abcdef');
?>
With this trick, the opcache will be reset in a.php and when b.php will be included, the constants will not be in cache anymore.