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 ?

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 :

<?
function arcad_func( $var_a )
{
echo $vara ;
}
;
function arcad_func( $var_a , $var_b )
{
echo $vara  . $var_b ;
}
?>

<?
arcad_func("Hello!");
arcad_func("Hello" , "World!")
?>

Would this work ?

Thanks...

----- Original Message -----
From: "Alexander Skwar" <[EMAIL PROTECTED]>
To: "Boget, Chris" <[EMAIL PROTECTED]>
Cc: "Arcadius A." <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, August 31, 2001 8:21 AM
Subject: Re: [PHP] PHP_SELF or REQUEST_URI within Function ?


> So sprach »Boget, Chris« am 2001-08-31 um 10:22:28 -0500 :
> > True.  But take the following function:
> >
> > function processLotsOfFormVars() {
> >   global $fieldOne, $fieldTwo, $fieldThree, $fieldFour;
> >   global $fieldFive, $fieldSix, $fieldSeven;
> >   global $PHP_SELF, $REQUEST_URI;
> >   global $HTTP_REFERER;
> >
> >   echo "Field One is: $fieldOne<br>\n";
> >   echo "Field Two is: $fieldTwo<br>\n";
> > // etc
> > }
> >
> > OR you can do it this way:
> >
> > function processLotsOfFormVars() {
> >   echo "Field One is: $GLOBALS[fieldOne]<br>\n";
> >   echo "Field Two is: $GLOBALS[fieldTwo]<br>\n";
> > // etc
> > }
>
> Uh?  I don't see it.  The "matching" function 1 is:
>
> function processLotsOfFormVars() {
> global $fieldOne;
> global $fieldTwo;
>
> echo "Field One is: $fieldOne<br>\n";
> echo "Field Two is: $fieldTwo<br>\n";
> }
>
> this quite doesn't look as intimidating as the piece you wrote.  And
> even if there are 10 lines of 'global', I still like it a lot better,
> because it CLEARLY shows which form vars are going to be used.
>
> One of the downside of PHP IMHO is, that you do not have to define
> variables.  This leads to a lot of errors.  At least there should be a
> "option", which forces you to define variables, like maybe so:
>
> dim $some_var;
>
> this leads to easier readable code IMHO.
>
> > variables in a function.  Plus, if the function gets large,
> > it's easier to see where the value is coming from by using
> > the $GLOBALS variable.
>
> Now, that's the point I'm arguing here.  I don't think so.
>
> Alexander Skwar
> --
> How to quote: http://learn.to/quote (german) http://quote.6x.to (english)
> Homepage: http://www.digitalprojects.com   |   http://www.iso-top.de
>    iso-top.de - Die günstige Art an Linux Distributionen zu kommen
> Uptime: 2 days 2 hours 10 minutes
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to