PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Desactivación de Comillas Mágicas> <Porqué Usar Comillas Mágicas
Last updated: Fri, 22 Aug 2008

view this page in

Porqué No Usar Comillas Mágicas

  • Portabilidad Asumir que estén habilitadas, o deshabilitadas, afecta la portabilidad. Use get_magic_quotes_gpc() para verificar su valor, y escriba su código de forma acorde.
  • Rendimiento Ya que no todo fragmento de datos escapados es insertado en una base de datos, existe una pérdida en rendimiento al escapar todos esos datos. Simplemente llamar las funciones de escape (como addslashes()) en tiempo de ejecución es más eficiente. Aunque php.ini-dist habilita estas directivas por defecto, php.ini-recommended las deshabilita. Esta recomendación se hace principalmente por razones de rendimiento.
  • Inconveniencia Ya que no todos los datos necesitan ser escapados, con frecuencia resulta molesto ver datos escapados cuando no debieran estarlo. Por ejemplo, enviar un correo electrónico desde un formulario y ver un montón de \' en el mensaje. Arreglar esto puedo requerir un uso exagerado de stripslashes().


add a note add a note User Contributed Notes
Porqué No Usar Comillas Mágicas
sir dot steve dot h+php at gmail dot com
07-Dec-2007 05:45
I find it useful to define a simple utility function for magic quotes so the application functions as expected regardless of whether magic_quotes_gpc is on:

function strip_magic_slashes($str)
{
    return get_magic_quotes_gpc() ? stripslashes($str) : $str;
}

Which can be annoying to add the first time you reference every $_GET /$_POST/$_COOKIE variable, but it prevents you from demanding your users to change their configurations.
rjh at netcraft dot com
13-Jun-2007 11:50
Additionally, addslashes() is not a cure-all against SQL injection attacks. You should use your database's dedicated escape function (such as mysql_escape_string) or better yet, use parameterised queries through mysqli->prepare().
gerard at modusoperandi dot com dot au
14-May-2007 06:53
Apparently it will be removed in PHP 6:

http://www.php.net/~derick/meeting-notes.html#magic-quotes
11-Feb-2006 10:47
It is also important to disable Magic Quotes while in development enivronment. For the reasons mentioned above, not everybody is using Magic Quotes.

An application that works fine with Magic Quotes enabled may have security problems (ie can be subject to SQL attacks) when distributed.

 
show source | credits | sitemap | contact | advertising | mirror sites