Possible value types are $ _POST and $ _GET

Is it possible that there exists any type of value in $_GETor $_POSTthat is not an array or string?

For those who read code better, is it even possible to run this simple script on a web server and make it throw an exception?

// crash-me.php
<?php

function must_be_array_or_string($value) {
    if(is_string($value))
        return;
    if(is_array($value)) {
        foreach($value as $subValue)
            must_be_array_or_string($subValue);
        return;
    }
    throw new Exception("Value is " . gettype($value));
}

if(isset($_GET))
    must_be_array_or_string($_GET);

if(isset($_POST))
    must_be_array_or_string($_POST);
+5
source share
2 answers

With the exception of file uploads, values ​​are always strings or arrays.

+7
source

I believe that in the case of downloading files field 'error', and 'size'will be ints.

+1
source

All Articles