PHP Get Variable


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

This is just a simple function to get the variable without having to worry if its POST or GET, and even allows for a default value to be passed in case the variable was not found.


Copy this code and paste it in your HTML
  1. function getVar($str, $default="") {
  2. return (isset($_POST[$str]) ? $_POST[$str] : (isset($_GET[$str]) ? $_GET[$str] : $default));
  3. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.