You are here: Re: stripslashes vs quotes « PHP Programming Language « IT news, forums, messages
Re: stripslashes vs quotes

Posted by Robin on 07/25/07 08:52

Sergei Riaguzov wrote:
> On Tue, 24 Jul 2007 13:10:37 +0200, Michael Fesser wrote:
>
>> Slashes are produced by magic quotes, an old and absolutely broken
>> concept. Thankfully it will be removed in PHP 6. But for now you have to
>> call get_magic_quotes_gpc() to check if MQs are enabled. If that's the
>> case, call stripslashes() on the POST or GET values to get the raw data.
>> That's what you should always work with.
> OK, thank you! I will use "if (get_magic_quotes_gpc())" check before
> applying stripslashes() and won't apply it in case get_magic_quotes_gpc()
> returns false.

The ternary conditional operator comes in handy here, so your original
function call:

htmlspecialchars(stripslashes($_POST["blabla"]), ENT_QUOTES);

becomes

htmlspecialchars(get_magic_quotes_gpc()?stripslashes($_POST["blabla"]):$_POST["blabla"],ENT_QUOTES);

Robin

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация