Php 使用str_替换img src替换无效
嗨,我正试图修改我上传的一张图片的src,我想要一个完整的路径,我在这里看到了其他答案,但我不知道为什么我的代码不起作用,请看Php 使用str_替换img src替换无效,php,str-replace,ckfinder,Php,Str Replace,Ckfinder,嗨,我正试图修改我上传的一张图片的src,我想要一个完整的路径,我在这里看到了其他答案,但我不知道为什么我的代码不起作用,请看 $html = '<p> <img alt="" src="/deconsultas/javascript/ckfinder/files/images/xxx.jpg"/></p>'; $dato = str_replace("src="/deconsultas/javascript","a",$html); echo
$html = '<p> <img alt="" src="/deconsultas/javascript/ckfinder/files/images/xxx.jpg"/></p>';
$dato = str_replace("src="/deconsultas/javascript","a",$html);
echo $dato;
$html='';
$dato=str_replace(“src="/deconsultas/javascript”、“a”、$html);
echo$dato;
请问错误在哪里?我想您需要这个
$html = '<p> <img alt="" src="/deconsultas/javascript/ckfinder/files/images/xxx.jpg"/></p>';
$dato = preg_replace("/\/deconsultas\/javascript/","a",$html);
echo $dato;
$html='';
$dato=preg\u replace(“/\/deconsultas\/javascript/”、“a”、$html);
echo$dato;
只需将stru-replace(“src="/deconsultas/javascript”,“a”,“$html”)更改为stru-replace(“src=\”/deconsultas/javascript”,“a”,“$html)
用斜杠转义引号
使用
\"
而不是
&引用
在stru替换中,您使用了
“
”而不是“非常感谢!!但这就是为什么/\/和这个\/?”??