易截截图软件、单文件、免安装、纯绿色、仅160KB

php基础应用:php批量转换文件编码

遍历目录文件,替换编码部分,删除原文件,再重新转码原文件内容,重新生成新文件。
function explorerdir($sDir){

static $aTempArr=array();
$dp=opendir($sDir);
while ($sFileName = readdir($dp)){

if ($sFileName !='.' && $sFileName !='..'){

$sPath=$sDir."/" . $sFileName;
if ( is_dir($sPath)){

explorerdir($sPath);
} else {

// $filetime=date("Y-m-d H:i:s",filectime("$path"));
// $fp=$path.",".$filetime;
$fp=$sPath;
$aTempArr[]=$fp;
}
}
}
closedir($dp);
return $aTempArr;
}
$aFiles = explorerdir("D:/wamp/www/dedecms/templets/default");
foreach($aFiles as $iKey => $sFiles) {

$sContent = file_get_contents($sFiles);
$sContent = str_ireplace('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />', '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />', $sContent);
$sContent = iconv("UTF-8", "gb2312", $sContent);
unlink($sFiles);
file_put_contents($sFiles, $sContent);
unset($sContent);
}

原贴地址:http://topic.csdn.net/u/20100407/10/b5fe2152-d5b2-42a5-aa3f-cf6c499af2f1.html


相关文档:

PHP字符串经典函数

<?    
//------------------------    
// PHP内置字符串函数实现     
//------------------------    
   
//字符串长度    
function strlen ($str)     ......

PHP函数之setcookie()


setcookie("cookiename","cookievalue",time()+3600,"/path",".php100.com",1);
cookiename:
是cookie的名字,可以通过cookiename调用此cookie,$_COOKIE["cookiename"];
cookievalue:
是cookie的初始值;
time():
返回UNIX时间戳,即从1970年1月1日(UTC/GMT ......

PHP中str_replace函数使用数组

函数原型:mixed str_replace(mixed needle,mixed new_needle,mixed haystack[,int &count]);
      needle:要被替换的字符串,new_needle:替换用的字符串,haystack:操作字符串,count:替换次数【可选参数】
     我们重点试验前三个在使用数组是的执行方式:
&n ......

iptables + php 上网计费实现

最近有一个香港的酒店提出需求,要到酒店业内的商务中心实行计费上网, 提供了如下技术方案:
1、设一台CENTOS5的机器做为路由,把需要计费的机器都设为用此服务器做网关。
2、服务器开启IPTABLE,通过IPTABLE控制能不能使用互联网。
记录下以下技术要点:
一、 php可以通过shell_exec来执行shell指令,但iptables的指令是r ......

我的第一个PHP程序

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号