Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Odding http://xolox.ath.cx/

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Strip slashes from user input (if applicable)

This code checks if magic quotes are enabled, and if so, strips slashes from GET, POST and COOKIE arrays. It's fully recursive, and thus supports POST arrays.

   1  <?php
   2  
   3  // If magic quotes are enabled, strip slashes from all user data
   4  function stripslashes_recursive($var) {
   5  	return (is_array($var) ? array_map('stripslashes_recursive', $var) : stripslashes($var));
   6  }
   7  
   8  if (get_magic_quotes_gpc()) {
   9  	$_GET = stripslashes_recursive($_GET);
  10  	$_POST = stripslashes_recursive($_POST);
  11  	$_COOKIE = stripslashes_recursive($_COOKIE);
  12  }
  13  
  14  ?>
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS