php htmlspecialchars加强版

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

//取消HTML代码
function shtmlspecialchars($string) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = shtmlspecialchars($val);
}
} else {
$string = preg_replace(‘/&((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/', ‘&\\1′,
str_replace(array(‘&', ‘”‘, ‘<', ‘>'), array(‘&', ‘"', ‘<', ‘>'), $string));
}
return $string;
}

相关文章

使用php判断网页是否gzip压缩

昨天晚上群里有朋友采集网页时发现file_get_contents 获得的网页保存到本地为乱码,响应的header 里 Content-Encoding:gzip但在浏览器里看是正常的。...

PHP中使用Imagick操作PSD文件实例

参考资料: http://www.php.net/manual/zh/book.imagick.php 前提 复制代码 代码如下: $im = new Imagick("test.psd...

php压缩多个CSS为一个css的代码并缓存

复制代码 代码如下: <?php /* Compress multiple CSS files into one and cache for an hour. Use the sa...

ubuntu下编译安装xcache for php5.3 的具体操作步骤

wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gzsudo tar -xzvf  xc...

PHP 线程安全与非线程安全版本的区别深入解析

从2000年10月20日发布的第一个Windows版的PHP3.0.17开始的都是线程安全的版本,这是由于与Linux/Unix系统是采用多进程的工作方式不同的是Windows系统是采用...