opcache_compile_file

(PHP 5 >= 5.5.5, PHP 7, PHP 8, PECL ZendOpcache > 7.0.2)

opcache_compile_fileCompila e armazena em cache um script PHP sem executá-lo

Descrição

opcache_compile_file(string $filename): bool

Esta função compila um script PHP e o adiciona ao cache opcode sem executá-lo. Isso pode ser usado para preparar o cache após a reinicialização de um servidor da Web, armazenando previamente em cache os arquivos que serão incluídos em solicitações posteriores.

Parâmetros

filename

O caminho para o script PHP a ser compilado.

Valor Retornado

Retorna true se filename foi compilado com sucesso ou false em caso de falha.

Erros

Se filename não puder ser carregado ou compilado, um erro de nível E_WARNING será gerado. Você pode usar @ para suprimir este aviso.

Veja Também

add a note

User Contributed Notes 1 note

up
19
IceNV
5 years ago
Be aware that opcache will only compile and cache files older than the script execution start.

For instance, if you use a script to generate cache files (e.g. you don't have access to shmop and rely on opcache for in-memory data caching instead), opcache_compile_file will not include the generated file in the cache, because its modification time is after the script start.

The workaround is to use touch() to set a date before the script execution date, then opcache will compile and cache the generated file.
To Top