Hi I am just learning the PHP object oriented stuff with a book I bought. The book is pretty good but it doesn't explain why the following code doesn't work:
PHP Code:
<?php
class StaticCall { static $_static = -1; public function __construct() { //static $_static = -1; echo "<p>number is " . $_static; $_static = 1; echo "</p><p> and number is " . $_static; } }
$static = new StaticCall();
The page is supposed to display the first value of $_static but its blank. like the property is undefined. The second value displays fine as 1. Can someone explain this to me? Or is it my server?
Last edited by chrishirst; 04-21-2010 at 10:08 AM..
|