How to eliminate backslash in PHP

I constructed my xml file with javascript and I show it correctly with an alert like this :

<Voitures>
   <voiture par1="4" par2="1" par3="0"/>
   <voiture par1="3" par2="0" par3="0"/>
</Voitures>

But the problem is when I send it with ajax to a php file I obtain this result :

<Voitures>
   <voiture par1=\"4\" par2=\"1\" par3=\"0\"/>
   <voiture par1=\"3\" par2=\"0\" par3=\"0\"/>
</Voitures>

Thank you

Answers


Your PHP configuration has magic quotes enabled, which is a deprecated setting that nobody should be using anymore. It has been removed in PHP 5.4. Disable it now, or you risk writing code that will behave incorrectly when you upgrade to PHP 5.4.

If that's not possible, use stripslashes() on the value prior to doing anything else with it. Only do this if you really cannot disable magic quotes. Developing PHP software with magic quotes enabled is a very, very bad idea.


If you're trying to write good code and be future-proof, put this as the top of every file, or some common include file that gets used everywhere:

if (get_magic_quotes_gpc()) {
    trigger_error("Magic quotes are enabled; please disable them.", E_USER_ERROR);
}

This will make your application simply refuse to run if magic quotes are enabled.

If you have the option, ship a .htaccess file with your application that contains this:

php_flag magic_quotes_gpc Off

This will, if possible, disable magic quotes for your entire application when it is depolyed on Apache. If the Apache configuration does not permit php_flag directives in .htaccess files then this will cause an HTTP 500 error, which is miles better than letting your application run with magic quotes enabled.


Need Your Help

Java: Checking if a String is equal to a String

java string object methods equals

I have an issue where I am trying to compare an object's name (String) to another String, and I've tried using .equals() as well as == but neither seem to work in my case.

lejos filewriting to the NXT

java file-io lejos-nxj

I am new to java and lejos so please don't blame me if i'm asking rather dumb questions.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.