RE: [PHP] PHP_SELF or REQUEST_URI within Function ?

From: Date: Fri, 31 Aug 2001 15:46:37 +0000
Subject: RE: [PHP] PHP_SELF or REQUEST_URI within Function ?
Groups: php.general 
Request: Send a blank email to php-general+get-65501@lists.php.net to get a copy of this message
> Cool ... > Now that we're talking about PHP .... > I'd like to ask a question .... > You know the "overloading" function in C++ .... Is that > possible in PHP ? No, I do not believe so. > Basically , I'd like to define more than one function having > the same name but different number of variables/parameters ... > so PHP would know which one I'm calling depending on the > numbwer/type of the variables ... exemple : You can do this with variable parameters. Something along these lines: function myFunc( $requiredVar, $optionalVar1 = "", $optionalVar2 = "" ) { echo "$requiredVar<br>\n"; if( $optionalVar1 ) { echo "$optionalVar1<br>\n"; } // etc. } Alternately, if you need *alot* of optional vars, consider passing an array and check that. Chris

« previous php.general (#65501) next »