[PHP] class constructor overloading

2008-10-23 Thread Alain Roger
Hi, is it possible to overload the class construct(or) ? if yes, how ? thx. -- Alain Windows XP SP3 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008

Re: [PHP] class constructor overloading

2008-10-23 Thread David Otton
2008/10/23 Alain Roger [EMAIL PROTECTED]: is it possible to overload the class construct(or) ? if yes, how ? class A { function __construct() { echo A; } } class B extends A { function __construct() { echo B;

Re: [PHP] class constructor overloading

2008-10-23 Thread Alain Roger
thanks a lot, this is exactly what i needed. if the construct of based class A accept arguments, i guess that construct of class B must have the sames. moreover, i guess that something like that must be written: class A { function __construct($nameA) { ... } } class B extends A {

Re: [PHP] class constructor overloading

2008-10-23 Thread Jim Lucas
Alain Roger wrote: thanks a lot, this is exactly what i needed. if the construct of based class A accept arguments, i guess that construct of class B must have the sames. moreover, i guess that something like that must be written: class A { function __construct($nameA) { ... } } class

Re: [PHP] class constructor overloading

2008-10-23 Thread David Otton
2008/10/23 Alain Roger [EMAIL PROTECTED]: thanks a lot, this is exactly what i needed. if the construct of based class A accept arguments, i guess that construct of class B must have the sames. No, you can change the signature of a method when you overload it. Below, B::__construct() accepts 1

Re: [PHP] class constructor overloading

2008-10-23 Thread Jochem Maas
Alain Roger schreef: thanks a lot, this is exactly what i needed. if the construct of based class A accept arguments, i guess that construct of class B must have the sames. moreover, i guess that something like that must be written: I guess you find guessing preferable to RTFM and/or trying

Re: [PHP] class constructor overloading

2008-10-23 Thread Christoph Boget
is it possible to overload the class construct(or) ? if yes, how ? No, it's not. class A { function __construct() { echo A; } } class B extends A { function __construct() { echo B;

Re: [PHP] Class constructor

2006-02-01 Thread Marcus Bointon
On 31 Jan 2006, at 13:52, David Grant wrote: Drop __construct, PHP5 will call Test() anyway. From http://uk.php.net/manual/en/language.oop5.decon.php: For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor

[PHP] Class constructor

2006-01-31 Thread Georgi Ivanov
Hi, I'm writing a simple class. In order to be compatible with php4 and php5 I've done this : class test{ function Test(){ //This will be called in PHP4 } function __construct(){ //This will be called in PHP5 $this-Test();

Re: [PHP] Class constructor

2006-01-31 Thread Andrei
You could try with phpversion(). Georgi Ivanov wrote: Hi, I'm writing a simple class. In order to be compatible with php4 and php5 I've done this : class test{ function Test(){ //This will be called in PHP4 } function __construct(){

Re: [PHP] Class constructor

2006-01-31 Thread David Grant
Georgi, Drop __construct, PHP5 will call Test() anyway. From http://uk.php.net/manual/en/language.oop5.decon.php: For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. David

Re: [PHP] Class constructor

2006-01-31 Thread Georgi Ivanov
Yes, I noticed that PHP5 call the old way constructor, but what if in future version they drop this feature ? I think this is workaround for the problem . Or not ? On Tuesday January 31 2006 15:52, David Grant wrote: Georgi, Drop __construct, PHP5 will call Test() anyway. From

Re: [PHP] Class constructor

2006-01-31 Thread Richard Lynch
On Tue, January 31, 2006 7:46 am, Georgi Ivanov wrote: I'm writing a simple class. In order to be compatible with php4 and php5 I've done this : class test{ function Test(){ //This will be called in PHP4 } function __construct(){ //This will

[PHP] class constructor polymorphism

2005-04-08 Thread silverio . di
Hi to all, I'm a C++ programmer and I've to convert some simple classes from C++ to PHP. My toolbar_button class must have two or more constructors so I ask you if this is possible with PHP: class toolbar_button { CString m_name, m_tooltip, m_image, m_action; bool m_state,

Re: [PHP] class constructor polymorphism

2005-04-08 Thread Josip Dzolonga
[EMAIL PROTECTED] wrote: Hi to all, I'm a C++ programmer and I've to convert some simple classes from C++ to PHP. My toolbar_button class must have two or more constructors so I ask you if this is possible with PHP: You can't overload a constructor, I mean a function in PHP. Maybe extending two