Page 1 of 1

Function declaration

Posted: Wed Jul 30, 2003 5:56 am
by rabadu
Using Apache and Win32 CGI PHP 4.1.1, I wrote function declaration inside class:

class event extends item{

function eventType( $type ) {;}


After, in the same class, I have redeclared function to do something:

function eventType( $type ) {
-- functionality ---
}

Upgrading to PHP 4.3.2, I have get messagess like this:
Fatal error: cannot redeclare eventType() in ....

Is this something new in this version? Maybe the way I have declared then redeclared functions is not the usual way of coding? Please for advice.
Rgds,
RaBadu

Posted: Wed Jul 30, 2003 6:35 am
by mikusan
I am really bad at this, or i have never used this and i am curious.
Why would ou declare the same function twice, are you trying some overloading?

why is it that
function eventType( $type ) {;} you have a semicolon there?

Posted: Wed Jul 30, 2003 6:57 am
by rabadu
I have found this syntax in some PHP examples, and since in C or simillar languages it's normal or obligatory to first declare, I have found this very useful. No error has been reported until now (see PHP versions). It was useful for some templates, when function has not been overloaded in extended class, script works fine doing in fact nothing, because there is this strange declaration. Seems I have to delete all of this "declarations". The error is triggered in fact because in one class there is function declared twice.
Rgds