note 53838 added to language.oop5.decon

From: Date: Tue, 14 Jun 2005 20:42:15 +0000
Subject: note 53838 added to language.oop5.decon
Groups: php.notes 
Request: Send a blank email to php-notes+get-90432@lists.php.net to get a copy of this message
Even PHP 5 doesn't allow to redeclare a method in a class. So, it's impossible to create differents constructors to a object with unique parameters, something common JAVA. To overcome this limitation I've been forced to use something like this: <?php class MyClass { public $n1; public $n2; function MyClass ($n1 = FALSE, $n2 = FALSE) { if ($n1) { $this->n1 = $n1; } else { $this->n1 = 0; } if ($n2) { $this->n2 = $n2; } else { $this->n2 = mt_rand(); } } } ?> ---- Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53838 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53838&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53838&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53838&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53838&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53838&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53838&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90432) next »