SPLIB: strip_quotes.php

August 1, 2004 at 3:41 pm Leave a comment

Fairly early on in The PHP Anthology by Harry Fuecks, he suggests that Magic Quotes is a problem that all PHP developers has to deal with. Essentially, you must code with the idea that it is enabled, or that it is disabled… If you code as if it is enabled, you’ll run into issues when your app is running on a server that has it disabled. On the other hand, writing your application as if it is disabled will be an issue if it is enabled… Quite the quandry..

Harry’s answer? He includes a piece of code in SPLIB designed to detect if Magic Quotes is enabled, and if so, neutralize it’s effect, so it is as if it is disabled… This way, all your code can be written with the idea that Magic Quotes is off…

Good answer, I say, but I’ve ran into an issue… My test server has Magic Quotes enabled, so strip_quotes.php is active… When I include this piece of code in a script which receives an array of data from the remote web browser, the data gets basically lost… The variable is there, but it is a string variable, containing the word “Array”… I believe the specific failure is with the array_map function, which is what does the brunt of the work in strip_quotes.php.

Update:
I solved this problem with the array_map_deep function, which I found in the user notes section on php.net. Basically, it does the same thing as array_map, but it does so in a recursive fashion to any arrays it hits inside the passed array… I also posted my problem, and later my solution on the SitePoint forums. With any luck, this will be a standard part of SPLIB in the future.

Advertisements

Entry filed under: PHP.

Optimization FAQ is coming along nicely

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

August 2004
S M T W T F S
« Jul   Sep »
1234567
891011121314
15161718192021
22232425262728
293031  

Most Recent Posts


%d bloggers like this: