本文整理汇总了PHP中checkBOM函数的典型用法代码示例。如果您正苦于以下问题:PHP checkBOM函数的具体用法?PHP checkBOM怎么用?PHP checkBOM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkBOM函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trimbom_recursion
function trimbom_recursion($path)
{
$flag = FilesystemIterator::SKIP_DOTS | FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO;
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, $flag), RecursiveIteratorIterator::CHILD_FIRST);
foreach ($objects as $value) {
$realpath = $value->getRealpath();
$value->isFile() ? var_dump(checkBOM($value)) : true;
}
}
示例2: saveFile
public function saveFile($path, $conent)
{
$path = $this->baseDir() . $path;
$path = $this->trimPath($path);
$isBOM = checkBOM($path);
if ($isBOM) {
writeUTF8WithBOMFile($path, $conent);
return true;
} else {
return file_put_contents($path, $conent);
}
return false;
}
示例3: checkdir
function checkdir($basedir)
{
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
if (!is_dir($basedir . "/" . $file)) {
echo "filename: {$basedir}/\r\n\r\n{$file} " . checkBOM("{$basedir}/{$file}") . " <br>";
} else {
$dirname = $basedir . "/" . $file;
checkdir($dirname);
}
}
}
closedir($dh);
}
}
示例4: checkdir
function checkdir($basedir)
{
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
if (!is_dir($basedir . '/' . $file)) {
$filename = $basedir . '/' . $file;
echo 'filename:' . $basedir . '/' . $file . checkBOM($filename) . '<br>';
} else {
$dirname = $basedir . '/' . $file;
checkdir($dirname);
}
}
}
closedir($dh);
}
}
示例5: checkdir
function checkdir($basedir)
{
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..' && $file != '.svn') {
if (!is_dir($basedir . "/" . $file)) {
if (checkBOM("{$basedir}/{$file}") == 1) {
echo "filename: {$basedir}/{$file} <font color=red>tồn tại, đã tự động xóa.</font> <br>";
}
} else {
$dirname = $basedir . "/" . $file;
checkdir($dirname);
}
}
}
closedir($dh);
}
}
示例6: checkdir
function checkdir($basedir)
{
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
if (!is_dir($basedir . "/" . $file)) {
if (checkBOM("{$basedir}/{$file}") == 1) {
echo "filename: {$basedir}/{$file}<font color=red>found bom and remove!</font><br>";
}
} else {
$dirname = $basedir . "/" . $file;
checkdir($dirname);
}
}
}
closedir($dh);
}
}
示例7: checkdir
function checkdir($basedir)
{
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..' && $file != '.svn') {
if (!is_dir($basedir . "/" . $file)) {
$res = checkBOM("{$basedir}/{$file}");
if ($res != 'BOM Not Found.') {
echo "filename: {$basedir}/{$file} " . $res . " <br>";
}
} else {
$dirname = $basedir . "/" . $file;
checkdir($dirname);
}
}
}
closedir($dh);
}
}
示例8: checkdir
function checkdir($basedir = '', $loop = true)
{
$basedir = empty($basedir) ? '.' : $basedir;
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
if (!is_dir($basedir . '/' . $file)) {
echo '文件: ' . $basedir . '/' . $file . checkBOM($basedir . '/' . $file) . ' <br>';
} else {
if (!$loop) {
continue;
}
$dirname = $basedir . '/' . $file;
checkdir($dirname);
}
}
}
closedir($dh);
}
}
示例9: bakindata
/**
* 执行备份文件的SQL语句
*
* @param string $filename
*/
function bakindata($filename)
{
$DB = Database::getInstance();
$setchar = $DB->getMysqlVersion() > '4.1' ? "ALTER DATABASE `" . DB_NAME . "` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" : '';
$sql = file($filename);
if (isset($sql[0]) && !empty($sql[0]) && checkBOM($sql[0])) {
$sql[0] = substr($sql[0], 3);
}
array_unshift($sql, $setchar);
$query = '';
foreach ($sql as $value) {
$value = trim($value);
if (!$value || $value[0] == '#') {
continue;
}
if (preg_match("/\\;\$/i", $value)) {
$query .= $value;
if (preg_match("/^CREATE/i", $query)) {
$query = preg_replace("/\\DEFAULT CHARSET=([a-z0-9]+)/is", '', $query);
}
$DB->query($query);
$query = '';
} else {
$query .= $value;
}
}
}
示例10: while
//修改此行为需要检测的目录,点表示当前目录
if (isset($_GET['dir'])) {
$basedir = $_GET['dir'];
} else {
$basedir = ".";
}
//是否自动移除发现的BOM信息。1为是,0为否。
if (isset($_GET['auto'])) {
$auto = 0;
} else {
$auto = 1;
}
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..' && !is_dir($basedir . "/" . $file)) {
echo "filename: {$file} " . checkBOM("{$basedir}/{$file}") . " <br>";
}
if ($file != '.' && $file != '..' && is_dir($basedir . "/" . $file)) {
echo "<a href='?dir=" . $basedir . "/" . $file . "'>" . $basedir . "/" . $file . "</a><br>";
}
}
closedir($dh);
}
function checkBOM($filename)
{
global $auto;
$contents = file_get_contents($filename);
$charset[1] = substr($contents, 0, 1);
$charset[2] = substr($contents, 1, 1);
$charset[3] = substr($contents, 2, 1);
if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) {
示例11: checkdir
function checkdir($basedir)
{
static $num = 0;
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
if (!is_dir($basedir . "/" . $file)) {
if (file_ext($file) == 'php' && checkBOM("{$basedir}/{$file}", false)) {
echo "filename: {$basedir}/{$file} <b style='color:red'>bom found.</b><br/>";
$num++;
}
} else {
$dirname = $basedir . "/" . $file;
checkdir($dirname);
}
}
}
closedir($dh);
}
return $num;
}