Always remove slashes from GET and POST

This is a small piece of code that I use since many years. It removes all slashes from $_GET and…

Aprile 27, 2010

This is a small piece of code that I use since many years. It removes all slashes from $_GET and $_POST arrays if magic quote parameter is setted. Sometimes is usefull, put it at the beginning of your scripts…

if (get_magic_quotes_gpc()) {

	function slashes($e) { if (is_array($e)) return array_map("slashes", $e); else return stripslashes($e); }
	if (isset ($_POST) && count($_POST)) $_POST = array_map("slashes", $_POST);
	if (isset ($_GET) && count($_GET)) $_GET = array_map("slashes", $_GET);

}

Author

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.

Recommended

The Quantcast CMP broke my sites

A javascript error in CMP blocks my site.

Maggio 19, 2023

WP Gutenberg notes

Collection of notes and thoughts on Wordpress Gutenberg blocks development.

Gennaio 9, 2023

Optimizing LCP, Largest Contentful Paint result

Notes about Core Web Vitals optimization challenge

Gennaio 4, 2023

Find values recursively inside complex json objects in PHP

A PHP function to to quickly search complex, nested php structures for specific values.

Dicembre 18, 2022

Scroll to DIV by ID without jQuery

Use scrollIntoView instead of jQuery animate.

Dicembre 16, 2022