让这段正则:$str= preg_replace("/<img.*?src=\"(.+?)\".*?>/","<img src=\"\\1\" width='300' height='inherit'/>", $str);
输出后变成:<p><img width="300" height="inherit"></p>
自己尝试修改,发现无效:$str= preg_replace("/<img.*?src=\"(.+?)\".*?>/","<p><img src=\"\\1\" width='300' height='inherit'/><\/p>", $str);
$str = '<img src="http://php.p2hp.com/images/logos/php-logo.svg">';
$str = preg_replace("/<img.*?src=\"(.+?)\".*?>/", "<p><img src=\"\\1\" width=\"300\" height=\"inherit\"/></p>", $str);
exit($str);