Retrieving input from either GET/POST Today, I created an input class with a method to check whether or not input via GET/POST exists, and another method to retrieve input from either GET/POST, without having to check both individually.

class input {
        public static function exists($type = 'post') {
            switch ($type) {
                case "post":
                    return (!empty($_POST)) ? true : false;
                break;
                case "get":
                    return (!empty($_GET)) ? true : false;
                break;
                default:
                    return false;
                break;
            }

        }

        public static function get($data) {
            if (isset($_GET[$data])){
                return $_GET[$data];
            } else if (isset($_POST[$data])){
                return $_POST[$data];
            } else {
                return '';
            }
        } 
    }


Here is my form and example usage:

&lt;?php
    require_once('core/init.php');

    if(input::exists()){
        echo input::get('username');
        echo input::get('password');
        echo input::get('confirm_password');
    }

?&gt;

    &lt;form method="POST" autocomplete="off"&gt;
        &lt;div class="form-group"&gt;
            &lt;label for="username"&gt;
                Username
            &lt;/label&gt;
            &lt;input type="text" name="username" id="username" /&gt;     
        &lt;/div&gt;
        &lt;div class="form-group"&gt;
            &lt;label for="password"&gt;
                Password
            &lt;/label&gt;
            &lt;input type="password" name="password" id="password" /&gt;     
        &lt;/div&gt;
        &lt;div class="form-group"&gt;
            &lt;label for="confirm_password"&gt;
                Confirm Password
            &lt;/label&gt;
            &lt;input type="password" name="confirm_password" id="confirm_password" /&gt;     
        &lt;/div&gt;
        &lt;div class="form-group"&gt;
            &lt;input type="submit" /&gt;
        &lt;/div&gt;
    &lt;/form&gt; 


First of all, is it okay for me to access the methods in the way that I have? Is using statics in this way bad practice?

Secondly, aside from what I asked above, are there any recommendations or improvements that you can suggest?
I see a few small issues with the code:


Method names: particularly get is quite ambiguous, I'd use something more descriptive like 'get_element_data($element_name)' or something like that. As it is now it is obvious when used but it's not clear when looking just at the class itself.
Instead of  return (!empty($_GET)) ? true : false; you can actually use just return (!empty($_GET))
You don't need to break after return. Some might, however, argue that using it anyway is a good practice that prevents errors. So choose for yourself.


Other than that, I don't see any big problems with it.