<?php
function getfiles( $path , &$files = array() ) {
if ( !is_dir( $path ) ) return null;
$handle = opendir( $path );
while ( false !== ( $file = readdir( $handle ) ) ) {
if ( $file != '.' && $file != '..' ) {
$path2 = $path . '/' . $file;
if ( is_dir( $path2 ) ) {
getfiles( $path2 , $files );
} else {
if ( preg_match( "/\.(php|php5)$/i" , $file ) ) {
$files[] = $path2;
}
}
}
}
return $files;
}
$files = getfiles('/png/www/example.com/public_html/app/wordpress');
$br = (php_sapi_name() == "cli") ? "\n" : "<br />";
foreach($files as $file){
opcache_compile_file($file);
echo $file.$br;
}