I'd like to know if it exists a way to call a specific optionnal argument on function call in PHP 5.6 or upper versions
e.g. with a function
public static function foo($string, $param2 = FALSE, $param3 = FALSE, $param4 = FALSE)
{
if($param2 === TRUE)
{
#Code that replace all 'e' in $String by 'a' for exemple
}
if($param3 === TRUE)
{
#Code that upper case $String for exemple
}
if($param4 === TRUE)
{
#Code that truncate $string to 4 characters for exemple
}
}
So as you can see here, all optionnals parameters can be set on TRUE or FALSE without any depedencies with the others optionnal parameter's setting.
At the momment, the way I'll call this function for truncate my string would be through setting $param4 'TRUE' like this :
foo($string, FALSE, FALSE, TRUE);
As I'm an informatician, I'm very lazy and so I don't want to write these two 'FALSE' every time while it's already pre-set.
Would there be a way/syntax to go directly to $param4 ?
Same question if I want to set ($param2 and $param4) or ($param3 and $param4).
I hope I've been clear enough and I thank you in advance.