LinuxSA Mailing list archives

Index: [thread] [date] [subject] [author]
  From: Alan Kennington <akenning@dog.topology.org>
  To  : LinuxSA <linuxsa@linuxsa.org.au>
  Date: Fri, 23 Jun 2000 16:16:17 +0930

Re: PHP3 bug (apparently)

Just in case there may be one soul out there who knows even
less about PHP than I do, here's the problem I had, and the
solution to it.

It seems that in PHP, global variables (i.e. variables external
to function definitions) are _not_ imported into the scope
of all functions by default.
You have to explicitly import variable names into the scope of
a function body using the "global" keyword.

The documentation of this is at:

http://au.php.net:81/manual/language.variables.scope.php

These conventions differ from those of C or Perl, or just about
any other langauge I've used.
I can see that there are some advantages in avoiding accidental
import of external variables, and in discouraging the practice
of accessing too many external variables from within function bodies,
such as is very easy to do in Perl.
In fact, you could say that Perl almost discourages the use of
function parameters because of their clumsy means of parameter
and return value passing.

To the PHP experts, my apologies for discussing elementary
language aspects in yet another post.

Cheerio,
Alan Kennington.

-- 
LinuxSA WWW: http://www.linuxsa.org.au/  IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
  mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject


Index: [thread] [date] [subject] [author]
Return to the LinuxSA Mailing List Information Page