简体   繁体   English

php 为什么 str_replace 不能与 html 一起使用

[英]php why str_replace not working with html

why here str_replace not working为什么这里 str_replace 不起作用

<?php
$str= '<div class=\"droppable\" ondrop=\"drop(event)\" ondragover=\"allowDrop(event)\"></div>';
echo str_replace('\"','"', $str);

i want to use str_replace with HTML tag.我想将 str_replace 与 HTML 标签一起使用。

As I get you want to remove the \ s to get proper HTML.当我得到你想要删除\ s 以获得正确的 HTML 时。

Better way should be -更好的方法应该是 -

stripslashes('<div class=\"droppable\" ondrop=\"drop(event)\" ondragover=\"allowDrop(event)\"></div>');

Output Output

<div class="droppable" ondrop="drop(event)" ondragover="allowDrop(event)"></div>

stripslashes带斜杠

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM