<?php // simple PHP 5 script $GLOBALS['MyClass::$instance'] = NULL; /* class private static property */ define('MYCLASS_ANY_CONST', 10); /* class constant */ class MyClass /* implements iTemplate */ { var $b = 'hello world'; /* protected */ /** * Singleton demo */ function singleton() /* static */ { if (!isset($GLOBALS['MyClass::$instance'])) { $c = __CLASS__; $GLOBALS['MyClass::$instance']= new $c; } return $GLOBALS['MyClass::$instance']; } } $test = MyClass::singleton(); ?>