Calling functions with null variables


New member
Exactly why does this happen? PHP 8.1.
$whatever = funcSomeFunction($aFinalArrayWP, $aFinalArrayEP, $_REQUEST['var1'], $_REQUEST['var2']);
Sometimes $_REQUEST['var2'] is undefined. Its null I guess.

This is the function:
function funcSomeFunction($aFinalArrayWP = "", $aFinalArrayEP = "", $iVar1 = 1, $iVar2 = 0) { ... }

It works if $_REQUEST['var2'] is defined, if not I get this error:
PHP Fatal error: Uncaught TypeError: Unsupported operand types: string + string in... funcSomeFunction(Array, Array, '1', '')

Why? If $_REQUEST['var2'] is null shouldn't it be equal to 0 within the function? If I force $_REQUEST['var2'] = 0 it works fine.