When you use Input::get('foo', 'bar') to get a default value for 'foo', it works good if the parameter doesnt exist.
But if you access for example /?foo=, the default value is ignored.
The function controlling this is value() (http://laravel.com/api/source-function-value.html#849-858)
I think there is something used here like isset() instead of empty(), but to me, an empty value should be considered empty and default should appear instead.
Well, while talking in IRC about this, i noticed that this makes sense for querystring values. But for post values from a form, this situation would break things.
so after all i think this must be leave as it is. Or at least just fix it for querystrings where having an empty value is the same as having a null one.
Example that breaks the "Don't Repeat Yourself": example.com/?section=
$section = Input::get('section', 'index');
if ($section == '') {
$section = 'index';
}
Well, while talking in IRC about this, i noticed that this makes sense for querystring values. But for post values from a form, this situation would break things.
It impossible to only cater $_GET since Symfony merged all of it when a request object is created.
$section = Input::get('section', 'index');
Above code are the same for $_GET and $_POST.
No intention to change this behavior.
Just to add a workaround: Input::get('foo') ?: 'bar'
Just to add a workaround:
Input::get('foo') ?: 'bar'
It's weird but I am still getting this behavior in version 7.x.x. this workaround seems to fix it.
Most helpful comment
Just to add a workaround:
Input::get('foo') ?: 'bar'