Re: PHP 4.0 Bug #7553: RFC: Uplevel Block structure

From: Date: Tue, 31 Oct 2000 22:47:20 +0000
Subject: Re: PHP 4.0 Bug #7553: RFC: Uplevel Block structure
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-36561@lists.php.net to get a copy of this message
[clip] > > With the proposed Uplevel syntax, the previous code would look like this ... > > function export_script_vars( $var_names ) { > $result = ""; > uplevel { > foreach ($var_names as $var_name) { > $result .= '<input type=hidden name="$var_name" value = > "${$var_name}"/><br>' > } > return $result; > } > } > > With this addition, this opens great possibilities, though i can imagine the need to also be > cautious. > > Thanks for making PHP the great tool it is! It's not hard to write a function that does as such without the use of a structure like that, though I can't see it being bad to have-- example: function export_script_vars($var_names) { $result = ""; foreach ($var_names as $var_name) { $result .= '<input type="hidden" name="$var_name" value="${$GLOBALS["$var_name"]}" /><br /> } return $result; } This works provided that you are calling this from the top-level, and if not, you have to export your variables out to the top level with $GLOBALS. It should work, though. Chris

« previous php.dev (#36561) next »