Hello! There is a code:
function($somevar_1, $somevar_2) { //code... } I need that if the $somevar_2 parameter is not passed, then it will be assigned a default value. The manual says that you can do this:
function($somevar_1, $somevar_2 = 'string') { //code... } But the problem is that I need to set the default value as another variable. I tried to do this:
$arg = 'string'; function($somevar_1, $somevar_2 = $arg) { //code... } This code does not work. Gives an error message:Constant expression contains invalid operations
What to do?
null, check in the code, and ifnull, then replace the destination of the first argument. - terana($b, $c = null)and you writea(0)then this is just beautiful for you, the actual call will bea(0, null)that is, at the stage of the parser, or whatever. and so in principle in any language, I guess. - terannull, everything worked out - User_274