Function declaration

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rabadu
Forum Newbie
Posts: 2
Joined: Wed Jul 30, 2003 5:56 am
Location: Slovenia

Function declaration

Post 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
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post 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?
rabadu
Forum Newbie
Posts: 2
Joined: Wed Jul 30, 2003 5:56 am
Location: Slovenia

Post 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
Post Reply