I am racking my brain here. Just when I think I am understanding something, I am proven wrong.
My question involves using a static method, static variable, and the __construct magic method. Let's look at this example
<?php
class DummyStatic
{
public static $variable;
public function __construct()
{
self::$variable = 'Dummy Text';
}
public static function text()
{
return self::$variable;
}
}
$dummyText = DummyStatic::text();
?>
I was under the assumption that when I call DummyStatic::text(); that it would return Dummy Text.
I am using an MVC in another project where something like this is being done with success but why it doesn't work being stand alone is driving me crazy.
Any thoughts?
Thank you in advance.
Don't initialize static variables in the constructor...It seems that it could be very beneficial at times. Could you explain?