PHP 7.0.6 Released

opcache_reset

(PHP 5 >= 5.5.0, PHP 7, PECL ZendOpcache >= 7.0.0)

opcache_resetResets the contents of the opcode cache

Description

boolean opcache_reset ( void )

This function resets the entire opcode cache. After calling opcache_reset(), all scripts will be reloaded and reparsed the next time they are hit.

Parameters

This function has no parameters.

Return Values

Returns TRUE if the opcode cache was reset, or FALSE if the opcode cache is disabled.

See Also

User Contributed Notes

Anonymous
7 months ago
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.
antoine dot vdsk at gmail dot com
9 months ago
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.
To Top