note 78430 added to language.oop5.decon
| From: | magusdotxionatgmaildotcom at osu1 dot php dot net | Date: | Thu, 11 Oct 2007 19:20:33 +0000 |
| Subject: | note 78430 added to language.oop5.decon | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131309@lists.php.net to get a copy of this message | ||
Looking through the notes I noticed a few people expressing concern that PHP5 does not support
multiple constructors...
Here is an example of a method that I use which seems to work fine:
class Example
{
function __construct()
{
echo "do some basic stuff here";
}
function Example($arg)
{
echo $arg;
}
}
You then can call with or without arguments without having notices and/or warnings thrown at you...
Of course this is limited but if you don't need something complex this can help to get the job
done in some situations. I believe you could also add arguments to the __construct() function and
as long as it is different than Example() 's args you would be fine. Although I have yet to
test this.
----
Server IP: 64.71.164.2
Probable Submitter: 72.12.219.139
----
Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php
Edit -- https://master.php.net/note/edit/78430
Del: integrated -- https://master.php.net/note/delete/78430/integrated
Del: useless -- https://master.php.net/note/delete/78430/useless
Del: bad code -- https://master.php.net/note/delete/78430/bad+code
Del: spam -- https://master.php.net/note/delete/78430/spam
Del: non-english -- https://master.php.net/note/delete/78430/non-english
Del: in docs -- https://master.php.net/note/delete/78430/in+docs
Del: other reasons-- https://master.php.net/note/delete/78430
Reject -- https://master.php.net/note/reject/78430
Search -- https://master.php.net/manage/user-notes.php