¿Por qué mi texto citado aparece \"así\"? [duplicar]

Posible duplicado:
Problema de "barra inclinada antes de cada cita"

I am passing messages between different parts of my php application using code that looks like this:

$msg='"'.$_REQUEST['site'].'" modified.';
header('Location: sites.php?msg='.$msg);

The code that picks it up on the other end look like this:

<?php if (isset($_GET['msg'])) {echo '<p><em>'.$_GET['msg'].'</em></p>';}?>

In my development environment, the output looks like this: "Some site" modified. In my production environment, the output looks like this: \"Some site\" modificado.

This leads me to believe that it is a difference in the settings in the php.ini between the environments. I've searched until my eyeballs are blistered, but I can't find the difference. What gets passed in the url looks like this:

sites.php?msg="Some site" modified

If I put this code:


between the variable assignment and header call above, the url looks like this:

sites.php?msg=&quot;Some site&quot; modified.

But no message is displayed in either environment. I also have a similar problem if $_REQUEST['site'] contains an ampersand.

Can anyone explain what is going on here, and how to fix it?

preguntado el 24 de agosto de 12 a las 08:08

You probably have magic quotes enabled on your production environment. Check this out php.net/manual/en/security.magicquotes.php -

I had previously turn off magic quotes, so I assumed that wasn't the problem. The answer came back so resoundingly magic quotes, that I thought I'd check it again. This application is actually installed on a subdomain on my site and magic quotes defaulted to on for that subdomain. Doh! Thanks for the help. Curious to see if it breaks my wordpress installation on that subdomain when I turn it off... -

3 Respuestas

La configuración se llama magic_quotes_gpc

Respondido 24 ago 12, 08:08

Tienes Magic Quotes enabled set them disabled in PHP.INI.

Respondido 24 ago 12, 08:08

Use stripslashes: http://php.net/manual/en/function.stripslashes.php

<?php if (isset($_GET['msg'])) {echo '<p><em>'.stripslashes($_GET['msg']).'</em></p>';}?>

Respondido 24 ago 12, 08:08

Best to solve the problem, not hide the symptoms. - vascoblanco

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.