variable variables in global - bug?

php.internals

Greg Beaver

23 years ago
Hi, It was brought to my attention that this code is legal in PHP 4: function foo($param = 'test') { global $$param; echo $$param; } $test = 'bar'; foo(); // prints bar Is this a feature or a bug? (Should we support this syntax in phpDocumentor, or might it change in php 5?) Greg
-- phpDocumentor http://www.phpdoc.org

Sara Golemon

23 years ago
> It was brought to my attention that this code is legal in PHP 4: > > function foo($param = 'test') > { > global $$param; > echo $$param; > } > > $test = 'bar'; > foo(); // prints bar > > Is this a feature or a bug? (Should we support this syntax in > phpDocumentor, or might it change in php 5?) >
It's a feature, and it ain't goin' nowhere.

John Coggeshall

23 years ago
I just checked out a copy of HEAD and can't build PHP5, it looks like some changes were made to rename everything from php4->php5 and there are still some php4 references floating around that end up in the Makefile: [php@localhost ~/php5]$ make make: *** No rule to make target `libphp4.la', needed by `all'. Stop. Looking in the MakeFile one of the problems is OVERALL_TARGET (which points to libphp4.la instead of libphp5.la) but changing that alone isn't fixing it. Since I am sure there are those who know the build system better than I maybe someone else could look at it. John -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~- John Coggeshall john at coggeshall dot org http://www.coggeshall.org/ -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-

John Coggeshall

23 years ago
N/M... ./buildconf is a wonderful thing... (whoops) -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~- John Coggeshall john at coggeshall dot org http://www.coggeshall.org/ -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-