MiniLight 最近的时间轴更新
MiniLight

MiniLight

V2EX 第 6725 号会员,加入于 2011-03-15 04:09:26 +08:00
MiniLight 最近回复了
2011-04-02 22:40:37 +08:00
回复了 fim8 创建的主题 问与答 中国哪个ISP运营商没有广告推送?
我是河北联通的,以前遇到过,最近好像少了
BOM 标记会带来很多未知问题 大名鼎鼎的“锟斤拷”就出自于此 是不被推荐使用的 这段代码放在服务器上可以帮助你去除PHP文件中隐藏的 BOM 标记

<?php
//remove the utf-8 boms
//by magicbug at gmail dot com

if (isset($_GET['dir'])){ //config the basedir
$basedir=$_GET['dir'];
}else{
$basedir = '.';
}

$auto = 1;

checkdir($basedir);

function checkdir($basedir){
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..'){
if (!is_dir($basedir."/".$file)) {
echo "filename: $basedir/
$file ".checkBOM("$basedir/$file")." <br>";
}else{
$dirname = $basedir."/".
$file;
checkdir($dirname);
}
}
}
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) {
if ($auto == 1) {
$rest = substr($contents, 3);
rewrite ($filename, $rest);
return ("<font color=red>BOM found,
automatically removed.</font>");
} else {
return ("<font color=red>BOM found.
</font>");
}
}
else return ("BOM Not Found.");
}

function rewrite ($filename, $data) {
$filenum = fopen($filename, "w");
flock($filenum, LOCK_EX);
fwrite($filenum, $data);
fclose($filenum);
}
?>
@rabbit2nd 就是把需要用到的文件都放进一个文件里,然后开一张表,里面记下每个文件的名字和偏移地址。。。

貌似很多大型游戏都是这样做的
@yelusiku 可以把你需要的文件都写进一个名字固定的资源文件里,用的时候按需提取就可以了
好久以前看过PHP版的v2ex
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3271 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 11:44 · PVG 19:44 · LAX 04:44 · JFK 07:44
Developed with CodeLauncher
♥ Do have faith in what you're doing.