$str = '<div style="margin: 0px auto; width: 740px;"> <p><img width="748" height="444" alt="" src="/images/upload/Image/manmiao_0001.jpg" /></p></div>';
//去掉图片宽度
$search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
//去掉图片高度
$search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
//$content = preg_replace($search,'$1$3',$str);
//$content = preg_replace($search1,'$1$3',$content);
//去掉div的style
$content = preg_replace("/style=.+?['|\"]/i",'',$content);//这种方式很简单易懂,但因为太简单,不知道有没有漏洞,否则去掉图片的宽高也用这种方法写了
$content = preg_replace("/<img (.*)\/>/i",'',$str);//这种方式很简单易懂,但因为太简单,不知道有没有漏洞,否则去掉图片的宽高也用这种方法写了
require_once "class/main.php";
$obj=new main();
exit;
highlight_string($content);