RE: [PHP] Question regarding OOP and interitance

2003-09-04 Thread Jay Blanchard
[snip]
I would like to know a constructor function is also inherited to a child
class.
I mean the child class also needs to have a constructor function but it
must
have the same name as the class name.
How does that work?
[/snip]

FYI ... anything below PHP5 has a pseudo constructor. Since you are
inheriting the class the 'constructor' for the parent class should work.
If it doesn't (I have not tested it, and neither have you)then the class
extension can contain a 'contstructor' that is a duplicate of the parent
class 'constructor' but with the extension name. You'll have to test it
to make sure.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Question regarding OOP and interitance

2003-09-04 Thread Decapode Azur

 FYI ... anything below PHP5 has a pseudo constructor.

And how will it be in PHP5 ?


 Since you are inheriting the class the 'constructor' for the parent class
 should work. If it doesn't (I have not tested it, and neither have
 you)then the class extension can contain a 'contstructor' that is a
 duplicate of the parent class 'constructor' but with the extension name.
 You'll have to test it to make sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Question regarding OOP and interitance

2003-09-04 Thread Jay Blanchard
[snip]
 FYI ... anything below PHP5 has a pseudo constructor.

And how will it be in PHP5 ?
[/snip]

PHP5 will be using the Zend 2 Engine, and gives a standard way of
declaring constructor methods by calling them by the name __construct().


An example from http://www.php.net/zend-engine-2.php

?php
class BaseClass {
function __construct() {
print In BaseClass constructor\n;
}
}

class SubClass extends BaseClass {
function __construct() {
parent::__construct();
print In SubClass constructor\n;
}
}

$obj = new BaseClass();
$obj = new SubClass();
? 

True destructors will also be available, as should be true private
methods.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php