存档在六月, 2007年
最完整的phpescape函数
六 29th
function phpescape($str){
preg_match_all(“/[\x80-\xff].|[\x01-\x7f]+/”,$str,$newstr);
$ar = $newstr[0];
foreach($ar as $k=>$v){
if(ord($ar[$k])>=127){
$tmpString=bin2hex(iconv(“GBK”,”ucs-2″,$v));
if (!eregi(“WIN”,PHP_OS)){
$tmpString = substr($tmpString,2,2).substr($tmpString,0,2);
}
$reString.=”%u”.$tmpString;
} else {
$reString.= rawurlencode($v);
}
}
return $reString;
}
//该方法在某些linux系统下,
//会因为iconv的php版本问题
//造成该函数方法无法正常使用
//使用前请测试先
function phpescape($str) {
preg_match_all(“/[€-ÿ].|[-]+/”,$str,$r);
$ar = $r[0];
foreach($ar as $k=>$v) {
if(ord($v[0]) < 128){
$ar[$k] = rawurlencode($v);
echo $ar[$k].”<BR>”;
}
else {
$ar[$k] = “%u”.bin2hex(iconv(“GBK”,”ISO-10646-UCS-2″,$v)); //此处GBK为目标代码的编码格式,请实际情况修改
echo $ar[$k].”<BR>”;
}
[...]
禁止PHP缓冲的好办法
六 14th
头部加入
$GLOBALS['now'] = gmdate(‘D, d M Y H:i:s’) . ‘ GMT’;
header(‘Expires: 0′); // rfc2616 – Section 14.21
header(‘Last-Modified: ‘ . $GLOBALS['now']);
header(‘Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0′); // HTTP/1.1
header(‘Pragma: no-cache’); // HTTP/1.0
开源php企业网站整站
六 7th
开源php企业网站程序。
网站使用:php+adodb+smarttemplate+access(mdb)
网站演示:http://www.hzcnnet.com
支持:http://www.tsingfeng.com/article.asp?id=494
后台:admin/Admin_login.php admin文件夹可以改名
id/password:admin/admin
编辑器为ewebeditor4.0
无后门,无病毒,无私奉献。
hzcnnetfinal.rar
一个捕获函数输出的函数
六 5th
<?
/**
* 捕获一个函数的输出
* example:get_output(array($this,’test’));
*/
function get_output($array)
{
ob_start();
call_user_func($array);
return ob_get_clean();
}
?>