global - PHP function written in 5.5 throws error when upgraded to 7.0 -
here function worked prior upgrading 7.0
function set_session_vars() { $nb_args=func_num_args(); $arg_list=func_get_args(); for($i=0;$i<$nb_args;$i++) { global $$arg_list[$i]; $_session[$arg_list[$i]] = $$arg_list[$i]; }
}
now causer error says:
parse error: syntax error, unexpected '[', expecting ',' or ';' in /home/mvyc1956/public_html/members/includes/functions.php on line 322
i believe related non backward compatable changes global , use of $$ , arrays, php not enough figure out.
is there familiar why line :
global $$arg_list[$i];
which line 322 being reported cause of error, failing now, , recommend change code in order have work php 7?
i did googling , found this page again, im not understanding needs changed.
thanks
says syntax error of code in function no longer valid, take php 7 expert see it.
update removed word global above code , app "seems" working fine ask:
does know specifically, why global non compatibility issue? , fix of removing solid 1 or there better practice or removal come haunt me?
backward incompatible changes:
global accepts simple variables
variable variables can no longer used global keyword. curly brace syntax can used emulate previous behaviour if required:
// valid in php 5 only. global $$foo->bar; // valid in php 5 , 7. global ${$foo->bar};
so in case should become:
global ${$arg_list[$i]};
Comments
Post a Comment