简体   繁体   中英

How to echo a string with single quotes without backslash

Here is my code

$user_data = "I'm awesome";
echo $user_data;

This for some reason echoes I\\'m awesome in my site. I found this odd and weird. I put it in a variable because the value of this changes within the action of a function, searching through a MySQL Database. I cannot find the problem. Please HELP!

I would use stripslashes() function

$user_data = "I'm awesome";
$user_data = stripslashes($user_data);
echo $user_data;

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