简体   繁体   中英

php why str_replace not working with html

why here str_replace not working

<?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.

As I get you want to remove the \ s to get proper HTML.

Better way should be -

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

Output

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

stripslashes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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