So sprach »Boget, Chris« am 2001-08-31 um 10:22:28 -0500 :
> True.  But take the following function:
> function processLotsOfFormVars() {
>   global $fieldOne, $fieldTwo, $fieldThree, $fieldFour;
>   global $fieldFive, $fieldSix, $fieldSeven;
>   global $PHP_SELF, $REQUEST_URI;
>   global $HTTP_REFERER;
>   echo "Field One is: $fieldOne<br>\n";
>   echo "Field Two is: $fieldTwo<br>\n";
> // etc
> }
> OR you can do it this way:
> function processLotsOfFormVars() {
>   echo "Field One is: $GLOBALS[fieldOne]<br>\n";
>   echo "Field Two is: $GLOBALS[fieldTwo]<br>\n";
> // etc
> }

Uh?  I don't see it.  The "matching" function 1 is:

function processLotsOfFormVars() {
        global $fieldOne;
        global $fieldTwo;

        echo "Field One is: $fieldOne<br>\n";
        echo "Field Two is: $fieldTwo<br>\n";

this quite doesn't look as intimidating as the piece you wrote.  And
even if there are 10 lines of 'global', I still like it a lot better,
because it CLEARLY shows which form vars are going to be used.

One of the downside of PHP IMHO is, that you do not have to define
variables.  This leads to a lot of errors.  At least there should be a
"option", which forces you to define variables, like maybe so:

        dim $some_var;

this leads to easier readable code IMHO.

> variables in a function.  Plus, if the function gets large, 
> it's easier to see where the value is coming from by using
> the $GLOBALS variable.

Now, that's the point I'm arguing here.  I don't think so.

Alexander Skwar
How to quote: (german) (english)
Homepage:   | - Die günstige Art an Linux Distributionen zu kommen
                Uptime: 2 days 2 hours 10 minutes

PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to