Jump to content

Global output/imput filtrer


drisate

Recommended Posts

since filtering external data is entirely dependent on how or why your using it there is no completely global and safe way of doing what you ask.

 

since there is no way to determine wether your going to need specific characters to remain intact (ie, if you want a user to submit raw html/php code etc - not a good idea but sometimes needed).

 

this is the only way i found that matches your request (any html entities will be converted)

<?php
$rcount = count($_REQUEST);
$rKeys = array_keys($_REQUEST);

for($i=0;$i<$rcount;$i++){
   $b4 = $_REQUEST[$rKeys[$i]];
   $_REQUEST[$rKeys[$i]] = htmlentities($_REQUEST[$rKeys[$i]]);
   $SAFE_REQUEST[$rKeys[$i]] = htmlentities($_REQUEST[$rKeys[$i]]);
}

print_r($SAFE_REQUEST['test']);
?>

 

this will use htmlentities() on every request variable, for more information on what htmlentities does visit http://uk2.php.net/manual/en/function.htmlentities.php

 

 

hope this helps,

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.