note 39764 deleted from language.oop.newref by danbrown

From: Date: Sat, 07 Nov 2009 19:11:14 +0000
Subject: note 39764 deleted from language.oop.newref by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162587@lists.php.net to get a copy of this message
Note Submitter: blueshadow822 at hotmail dot com ---- Original : rick_php_net at roundeye dot net Date : 01-Oct-2002 05:37 Modify : bitmore.co.kr class StaticList { var $list = 0; function StaticList($name = '') { global $master; if (!isset($master)) { print "creating new list $name<Br>\n"; //$master = $this; $master =& $this; $master->list = array(); }else { print "creating new list $name... using global list<br>\n"; } //$this->list =& $master->list; //$this->list = $master->list; return ($this); } function show() { if (is_array($this->list)) { if (count($this->list)) { reset($this->list); while (list($key, $value) = each($this->list)) { print "list[$key] => $value<br>\n"; } }else { print "list empty.<br>\n"; } }else { print "list is not a list.<br>\n"; } } function append($val) { if (!is_array($this->list)) { print "forced to create list...<br>\n"; $this->list = array(); }else { print "appending $val to list<br>\n"; $this->list[] = $val; } } } $a = new StaticList("a"); $a->append(1); $a->append(2); $b = new StaticList("b"); $b->append(3); $b->append(4); $a->append(5); $b->append(6); print "Contents of a:<br>\n"; $a->show(); print "Contents of a:<br>\n"; $b->show(); this Show Printing creating new list a appending 1 to list appending 2 to list creating new list b appending 3 to list appending 4 to list appending 5 to list appending 6 to list Contents of a: list[0] => 1 list[1] => 2 list[2] => 5 Contents of a: list[0] => 3 list[1] => 4 list[2] => 6

« previous php.notes (#162587) next »