On Wed, 2004-05-12 at 15:18, Mark Constable wrote: > On Wed, 12 May 2004 10:43 pm, Lieve Vissenaeken wrote: > > Please ,could anybody help me ? I'm not so familiar with PHP. > > > > I've the following problem with my code when I try to make an object from > > the class "forum" with the code "$test=new forum()". I always get a > > warning on this: "Warning: Missing argument 1 for forum() in > > /lvdata/www/tennis/php/sql.inc" > > Is it not possible to just make a default constructor and an other > > constructor like in JAVA ? > > Thanks for helping.... > > No, you cannot do this kind of method overloading, not like > this anyway. If you are using PHP5 you can kind of emulate > overloading by using the __call() function... some googling > will find examples. > > You can at least make the below work by removing the first > forum() instance and using > > function forum($naam=NULL,$tijd=NULL,$tekst=NULL) > > and test the incoming variables with isset() before attempting > to use any of them. If you assign default values to the method arguments, you cannot test them with isset() anymore, as they will be set. > > > class forum > > { > > var $naam; > > var $tijd; > > var $tekst; > > > > function forum() > > { > > } > > > > function forum($naam,$tijd,$tekst) > > { > > $this->naam=$naam; > > $this->tijd=$tijd; > > $this->tekst=$tekst; > > } > > } > > > > > > $test=new forum(); > > --markc
signature.asc
Description: This is a digitally signed message part