News for hackers. Stuff that matters.
Re:PHP Is A Husk by jamroom on Wednesday August 26, 2009 @11:59AM (#787394)
The default scope within a function is not global, and all global variables are available within a function by using the keyword "global". You can also access the superglobals, but that of course is optional.
Re:PHP Is A Husk by jacquesm on Wednesday August 26, 2009 @12:49PM (#787538)
hacking the procrast to be able to answer you...

The default scope is global, I did not say 'within a function'.

I know about the 'global' keyword, as does everybody else that has used PHP for more than 5 minutes.

If your language has a C like syntax and you have a default scope (which means that you can start executing code right from the first line without being in a function definition) then the default behaviour of a variable should be that it either does not exist inside a function (different scope) and throws an error or it should refer to the global variable.

To have a 'third option', which silently creates empty variables is very (no, make that extremely) poor design.

And no, I'm not telling how to break noprocrast :)