Posted By

ramy on 01/19/11


Tagged

get session post


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

qubestream


Clean and get global variable


 / Published in: PHP
 

  1. function cleanGlobal($global_array, $arg, $specialchars = true, $default = null) {
  2. if(key_exists($arg, $global_array) && $global_array[$arg] != null && $global_array[$arg] != "") {
  3. if($specialchars) {
  4. return htmlspecialchars($global_array[$arg]);
  5. } else {
  6. return $global_array[$arg];
  7. }
  8. } else {
  9. return $default;
  10. }
  11. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: ramy on January 19, 2011

Call like this : $myvar = cleanGlobal($_GET, 'myvar');

You need to login to post a comment.