0.0117421150208
$file = '1.txt';$start = microtime(1);for ($i=0; $i < 5000; $i++) { if (filemtime($file)) { ; }}echo microtime(1) - $start;
0.021714925766
$file = '1.txt';$start = microtime(1);for ($i=0; $i < 5000; $i++) { if (file_exists($file)) { ; }}echo microtime(1) - $start;
Вакуммность вопроса очевидна.
Тестировалось на EXT4 + CPU 75% под сторонние процессы
UPDATE 1kk итераций
filemtime 2.38509511948
exist 4.74010205269
Критика: обоснуйте приминение регулярок. Коды, привидённые раннее другими, видели? Что в них Вас не устраивает?
Что первым нашлось.
http://www.yanajy.com/sdelay-sam/css-only-for-ie.html
http://css-tricks.com/how-to-create-an-ie-only-stylesheet/
$times = array('06:00', '15:00', '21:00'); $lastModified = getTimePeriod(true, $times); if ( file_exists($filename) && filemtime($filename) > $lastModified ) { // если файл существует и время его модификации не устарело ...................... } else { // файл отсутствует или данные устарели file_put_contents($filename, $var); ...................... } function getTimePeriod($lastModified, $expires=array()){ $now = time(); if ( is_array($expires) ) { $timestamps = array(); foreach ($expires as $k => $time) { if ( ! is_numeric($time) ) { $time = strtotime($time); if ( false === $time || -1 === $time ) continue; if ( preg_match('/^\s*\d+(?:\s*:\s*\d+){1,2}\s*$/', $expires[$k]) ) { $timestamps[] = $time - 24*60*60; $timestamps[] = $time + 24*60*60; } } $timestamps[] = $time; } if ( $lastModified ) arsort($timestamps); else asort($timestamps); foreach ($timestamps as $time) { if ( $lastModified && $now >= $time || ! $lastModified && $now <= $time ) { $now = $time; break; } } } return $lastModified ? $now : $now - time(); }
Парочку баз забыли заюзать, ну и без goto почему?
Тайтл невнимательно прочёл.
http://www.php.net/manual/en/function.tmpfile.php
Войдите в адмику и вернитесь на сайт.
Баллов 8 отсыпьте.
file_put_contents?