Re: [PHP-DEV] PHP 4.0 Bug #7553: RFC: Uplevel Block structure From: chrisv <email protected>
Date: 10/31/00

[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

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>