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
相关文档:
http://blog.developers.api.sina.com.cn/?p=264
最近MemcacheDB邮件列表和研发部那边同事报告PHP的memcache客户端php-memcache经常出 现断连接的问题:
PHP Notice: Memcache::get(): Server ………. (tcp 11211) failed with: Failed reading line from stream (0) with pecl-memcache 3.*
&h ......
php config
1.安装Apache2.2
2.安装php5.2(注意选择所有的库文件)
3.将phpMyAdmin解压,拷贝至Apache2.2\htdocs\phpmyadmin(该路径可以自由改变)下。
4.修改配置文件:
1)修改php.ini
具体操作:
extension_dir = "C:\Program Files\PHP\ext" (536)
extension=php ......
<?php
$s = "new string";
//下面双引号字符串中的符号"$"未做转义,因此$s将被替换成其变量的值
$str_1 = "双引号指定的字符串,$s";
//下面双引号字符串中的符号"$"做了转义,因此$s原封不动,不会被替换为变量$s的值
$str_2 = "双引号指定的字符串,\$s";
//单引号字符串中的"$"不用做转义即可原样输出
$str_3 ......
1: apache服务器安装.apache_2.0.59-win32-x86-no_ssl.msi。
修改conf\httpd.conf中的文件,修改位置为:
DocumentRoot "c:/webpage" 设置虚拟目录 c:/webpage.
DirectoryIndex index.html index.html.var index.php
==使apache服务器识别php的扩展名。
在<Directory "c:/pr ......
从HTML文件中读取指定字符串
原贴地址:http://topic.csdn.net/u/20100322/10/d7401c38-10b7-4231-a323-454caf946fa6.html
2.
<a title="1" href="sdfds" m ......