RE: [PHP-DEV] Calling symbol table patch
| From: | Sterling Hughes | Date: | Sun, 19 Nov 2000 23:26:35 +0000 |
| Subject: | RE: [PHP-DEV] Calling symbol table patch | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-38720@lists.php.net to get a copy of this message | ||
-----Original Message-----
From: Andrei Zmievski [mailto:andrei@ispi.net]
Sent: Tuesday, November 21, 2000 12:06 AM
To: Sterling Hughes
Cc: Zeev Suraski; Andi Gutmans; PHP Developers
Subject: Re: [PHP-DEV] Calling symbol table patch
On Sun, 19 Nov 2000, Sterling Hughes wrote:
> The original purpose of the function as I created it was simply to output
> debug information, therefore:
>
> var_dump(get_defined_vars());
>
> Was easier than:
>
> var_dump(array_keys($GLOBALS));
> var_dump(get_defined_vars());
But your semantics are incorrect here, then. Global variables are not
automatically defined in the local scope, so get_defined_vars() should
not return them.
--
Correct :), but again my use for it was a debugging function that would get
all variables that are currently defined in the script (thus globals makes a
bit more sense).
> The way I see it there are a few options -->
>
> 1) Keep with my patch. This will not be so bad as long as you define
> "current" as the first argument.
> 2) Modify it so that the contents of variables in the current scope are
> returned, but not variables in the global
> scope. (this sucks imho)
Why?
--
Maybe I explained it wrong (this timezone difference in italy is killing
me, I'm less coherent than usual), I meant it would just return the names of
all the variables in the global scope to keep compatibility but then return
the names and the contents of the variables in the current scope. The only
justification for this is not to break what little backwards compatibility
is neccessary, and the semantics just don't make sense to me...
> 3) Break compatibility. The get_defined_vars() and
get_defined_functions()
> functions have not (to my knowledge) been formally announced,
therefore
> I don't think it will be killer to break compatibilty in
get_defined_vars()
> and have it simply return the current scope. (I like this the best)
That's what I suggested - just return the current scope.
--
Yup.
> I also don't think it should be get_symbol_table() since if I'm the
average
> user I know what a variable is but a symbol table, is that like some weird
> Perl thing? :)
Never hurts to educate people.
--
You want to explain to an HTML coder learning PHP Zend's symbol tables and
how it relates, be my guest (I'll take the death by fire personally ;). I
think get_defined_vars() gives a clearer indication of what its supposed to
do (give me all of the currently defined variables).
-Sterling
-Andrei
* Anything will fit if you push hard enough *