Page 1 of 1

how to remove \ in php string display

Posted: Tue Aug 25, 2009 1:09 am
by waseem83
My code is

$message="We're looking at developing our website.";

$body= "My message is,\n\n\n\n\t\t\t".$message";

echo $body;

I get result

We\'re looking at developing our website.

Can any body tell me how to remove \ from the printed string?

Thanks in advance

Re: how to remove \ in php string display

Posted: Tue Aug 25, 2009 1:12 am
by pbs
Use

Code: Select all

 
<?php
    stripslashes($str);
?>
 

Re: how to remove \ in php string display

Posted: Tue Aug 25, 2009 5:20 am
by MichaelR
Alternatively, if you have access to the config.ini file, turn magic_quotes_gpc to off, and remember to escape strings with mysql_real_escape_string() when you are performing an SQL query.

Re: how to remove \ in php string display

Posted: Tue Aug 25, 2009 6:44 am
by jackpf
Oooooor, if you don't have access to your php.ini, you can turn off magic quotes in a htaccess file with a php_flag.

Re: how to remove \ in php string display

Posted: Thu Aug 27, 2009 4:59 am
by Jenk
Aaaaaaaaand you can post in the correct section. Coding Critique is not for general coding questions, help with errors, etc.