Open
Description
Description
The following code:
<?php
var_dump(filter_var("a", FILTER_VALIDATE_INT, ['flags' => FILTER_REQUIRE_ARRAY, 'options' => ['default' => 'Failed']]));
var_dump(filter_var([1], FILTER_VALIDATE_INT, ['flags' => FILTER_REQUIRE_ARRAY, 'options' => ['default' => 'Failed']]));
var_dump(filter_var(["a"], FILTER_VALIDATE_INT, ['flags' => FILTER_REQUIRE_ARRAY, 'options' => ['default' => 'Failed']]));
var_dump(filter_var("a", FILTER_VALIDATE_INT, ['options' => ['default' => 'Failed']]));
Resulted in this output:
bool(false)
array(1) {[0]=> int(1)}
array(1) {[0]=> string(6) "Failed"}
string(6) "Failed"
But I expected this output instead:
array(1) {[0]=> string(6) "Failed"} or string(6) "Failed"
array(1) {[0]=> int(1)}
array(1) {[0]=> string(6) "Failed"}
string(6) "Failed"
Since the documentation says:
default
, value to return if the filter fails
I was expecting to get at least some form of Failed
.
PHP Version
PHP 8.3
Operating System
Windows 11