Clean and get global variable


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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

You need to login to post a comment.