opcache_invalidate

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

opcache_invalidate — Invalidates a cached script

Description

function opcache_invalidate(string $filename, bool $force = false): bool

This function invalidates a particular script from the opcode cache. If force is unset or false, the script will only be invalidated if the modification time of the script is newer than the cached opcodes. If the opcache.file_cache directive is enabled, this function also invalidates the corresponding file cache entry.

Warning

Avoid calling this function with untrusted input. When the opcache.file_cache directive is enabled and opcache.file_cache_read_only is not enabled, a filename that starts with one or more ../ can escape from the opcache file cache directory and allow deleting any file ending in .bin that the user has permission to delete. This includes files to which open_basedir might otherwise limit access.

Parameters

filename

The path to the script being invalidated.

force

If set to true, the script will be invalidated regardless of whether invalidation is necessary.

Return Values

Returns true if the opcode cache for filename was invalidated or if there was nothing to invalidate, or false if the opcode cache is disabled.

See Also