static vs global variable - Page 2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: static vs global variable

Bernd Schulz wrote:
Quoted text here. Click to load it
And what differentiates that from:

global $my_dangerous_global_x;


Apart from the fact that the latter is a lot less lines overall. And
probably executes faster.

You HAVE declared a global variable in philosophical terms. You have
just made it lexically complicated (and in machine cycles, longer) to
access it.

Imagine trying to run the batsman out, but being REQUIRED to only throw
the ball to the wicket keeper, as he is the only man allowed to throw it
at the stumps..

All you do is shift your global object (the stumps) from being a simple
target, to the wicket keeper being the global object and the only way to
access the stumps.

I can see the point if you are playing cricket with 17 balls at once,
and you cant have two balls hitting it simultaneously, but just to play
the simple game? Pshaw!. Its madness!

Re: static vs global variable

On 2/27/2011 4:36 AM, Bernd Schulz wrote:
Quoted text here. Click to load it

You are a bit late to the table.  I already said this about four posts
ago and TNP keeps objecting.  (By the way, you left out the public
function setGlobal($value) {
    $this->global = $value;

and the declaration of
private $global;
as the class variable.

You would then have


Site Timeline