Re: constructors in PHP
| From: | Greg Donald | Date: | Mon, 11 Jul 2005 15:04:30 +0000 |
| Subject: | Re: constructors in PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-218443@lists.php.net to get a copy of this message | ||
On 7/11/05, Alessandro Rosa <zandor_zz@yahoo.it> wrote:
> Is there the possibility to have in PHP multiple class constructors
> as in C++ or just one ?
Doesn't seem as though you can:
> cat class.php
#!/usr/bin/php
<?php
error_reporting( E_ALL );
class Foo
{
function __construct()
{
}
function __construct()
{
}
}
$f = new Foo;
?>
> ./class.php
PHP Fatal error: Cannot redeclare __construct() in
/home/greg/class.php on line 13
Fatal error: Cannot redeclare __construct() in /home/greg/class.php on line 13
--
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/