A question about load_class function in Common.php |
[eluser]Crusoe[/eluser]
In this block of code Code: static $_classes = array(); The $isset test not make any sense. Can someone explain this please ?
[eluser]danmontgomery[/eluser]
It's checking if the class has already been loaded, in which case it doesn't load it again.
[eluser]Crusoe[/eluser]
The if (isset($_classes[$class])) will always return false because the array is being initialised in the previous line. It's meaningless to have that isset test there.
[eluser]danmontgomery[/eluser]
[quote author="Crusoe" date="1308065319"]The if (isset($_classes[$class])) will always return false because the array is being initialised in the previous line. It's meaningless to have that isset test there.[/quote] http://php.net/manual/en/language.variables.scope.php Quote:A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope.
[eluser]Crusoe[/eluser]
Ah. I see what you mean. Code: static $arry = array(); prints "hello world" I am new to PHP (uses C++ and C# mostly). Just getting used to PHP's peculiarities Thanks. |
Welcome Guest, Not a member yet? Register Sign In |