PHP tips

กรกฎาคม 8, 2007

check ตัวอักษร 0-9 a-Z และ ก-ฮ

Function preg_match
if( preg_match(“/^[0-9A-Zก-ฮ]$/”, $msg) ) {
      do something
} else {
     exit or do something
}

 —————————————————————————————–

cache

$cacheDir = dirname(__FILE__) . ‘/cache/’;

if (isset($_GET['id'])) {
   $cacheFile = $cacheDir . ‘_’ . $_GET['id'] . ‘.html’;
} else {
   $cacheFile = $cacheDir . ‘index.html’;
}

if (file_exists($cacheFile))
{
   header(“Content-Type: text/html”);
   readfile($cacheFile);
   exit;
}

// … more code coming

*** if your file to create cache is store in c:/webroot/
folder cache is c:/webroot/cache/

Leave a Reply