CodeIgniter Forums

Full Version: default value paramater for get/post/cookie input class
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
I don't see any better outlet for this type of recommendation - I would love to contribute more to CI as my team and I have been using it recently on several projects.

Anyway, instead of sending a default value of false if a parameter is not set, I would recommend that it be a third option in the function.

For example:

Code:
function post($index = '', $xss_clean = FALSE, $default = FALSE)
    {
        if ( ! isset($_POST[$index]))
        {
            return $default;
        }

Instead of returning false, I could assign a default value (which, by if not provided is false). I frequently need to assign something else, like a string or a non-zero integer.

I would recommend this for the get/post functions, if not the cookie/session functions as well.