note 96491 modified in function.session-start by danbrown

From: Date: Tue, 02 Mar 2010 15:31:29 +0000
Subject: note 96491 modified in function.session-start by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166527@lists.php.net to get a copy of this message
A handy script that checks fot the presence of uft-8 byte order mark (BOM) in all files in all directories starting on current dir. Combined from the work of other people here... <?php function fopen_utf8 ($filename) { $file = @fopen($filename, "r"); $bom = fread($file, 3); if ($bom != b"\xEF\xBB\xBF") { return false; } else { return true; } } function file_array($path, $exclude = ".|..|design", $recursive = true) { $path = rtrim($path, "/") . "/"; $folder_handle = opendir($path); $exclude_array = explode("|", $exclude); $result = array(); while(false !== ($filename = readdir($folder_handle))) { if(!in_array(strtolower($filename), $exclude_array)) { if(is_dir($path . $filename . "/")) { // Need to include full "path" or it's an infinite loop if($recursive) $result[] = file_array($path . $filename . "/", $exclude, true); } else { if ( fopen_utf8($path . $filename) ) { //$result[] = $filename; echo ($path . $filename . "<br>"); } } } } return $result; } $files = file_array("."); ?> --was-- A handy script that checks fot the presence of uft-8 byte order mark (BOM) in all files in all directories starting on current dir. Combined from the work of other people here... function fopen_utf8 ($filename) { $file = @fopen($filename, "r"); $bom = fread($file, 3); if ($bom != b"\xEF\xBB\xBF") { return false; } else { return true; } } function file_array($path, $exclude = ".|..|design", $recursive = true) { $path = rtrim($path, "/") . "/"; $folder_handle = opendir($path); $exclude_array = explode("|", $exclude); $result = array(); while(false !== ($filename = readdir($folder_handle))) { if(!in_array(strtolower($filename), $exclude_array)) { if(is_dir($path . $filename . "/")) { // Need to include full "path" or it's an infinite loop if($recursive) $result[] = file_array($path . $filename . "/", $exclude, true); } else { if ( fopen_utf8($path . $filename) ) { //$result[] = $filename; echo ($path . $filename . "<br>"); } } } } return $result; } $files = file_array("."); http://php.net/manual/en/function.session-start.php

« previous php.notes (#166527) next »