Re: Function Var or No Var

From: Date: Fri, 05 Jan 2001 12:58:37 +0000
Subject: Re: Function Var or No Var
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-32877@lists.php.net to get a copy of this message
It was just a "there's more than one way to do it". with func_get_arg( 0 ) you can call it with an empty string and still have it behave differently from a zero-arg-count situation. At 13:37 5.1. 2001, Hsieh Wen-Yang wrote the following: -------------------------------------------------------------- >----- Original Message ----- >From: "Cynic" <cynic@mail.cz> >To: "Hsieh Wen-Yang" <wh033@csufresno.edu>; "Abe Asghar" ><abe@fish.tm>; "PHP >LIST" <php-general@lists.php.net> >Sent: Friday, January 05, 2001 4:32 AM >Subject: Re: [PHP] Function Var or No Var > > >> um, I don't see the point. >> 1) he only needed _one_ argument > >Why not just use argument with default value if he know only one argument is >needed? > >> 2) $args = func_get_args() will be much faster. > >I do not know about this. Thank you for telling me though. > >> >> At 13:23 5.1. 2001, Hsieh Wen-Yang wrote the following: >> -------------------------------------------------------------- >> >function functionname() >> >{ >> > for($i=0; $i < func_num_args(); $i++) { >> > $arg[$i] = func_get_arg($i) ; >> > } >> > .... >> >} >> > >> >----- Original Message ----- >> >From: "Cynic" <cynic@mail.cz> >> >To: "Hsieh Wen-Yang" <wh033@csufresno.edu>; "Abe Asghar" >> ><abe@fish.tm>; >"PHP >> >LIST" <php-general@lists.php.net> >> >Sent: Friday, January 05, 2001 4:00 AM >> >Subject: Re: [PHP] Function Var or No Var >> > >> > >> >function functionname() >> >{ >> > if( 0 < func_num_args ) { >> > $arg = func_get_arg( 0 ) ; >> > } else { >> > ... >> >} >> > >> >At 12:48 5.1. 2001, Hsieh Wen-Yang wrote the following: >> >-------------------------------------------------------------- >> >>function functionname($arg=dafaultvalue) { >> >>.... >> >>} >> >> >> >>----- Original Message ----- >> >>From: "Abe Asghar" <abe@fish.tm> >> >>To: "PHP LIST" <php-general@lists.php.net> >> >>Sent: Friday, January 05, 2001 3:42 AM >> >>Subject: [PHP] Function Var or No Var >> >> >> >> >> >>Hey guys, >> >> >> >>I have a function in an external file. It is a footer function and is >> >>called on many pages. Now I want to pass it a varible from only one or >two >> >>pages. However the problem is that I want to pass it a variable from >one >> >>page and not from other pages e.g. >> >> >> >>1. >> >>DisplayFooter(); >> >> >> >>and >> >> >> >>2. >> >>DisplayFooter($currentpage); >> >> >> >>The function is set up to recieve the variable - doing this I get a >warning >> >>message where it is not sent a variable as in example 1. >> >> >> >>Is there a way to have a function that can take a variable and not >produce >> >>an error or have a default value if not sent a varible or value. >> >> >> >>Thanks for any help. >> >> >> >>Abe >> >> >> >> >> >>-- >> >>PHP General Mailing List (http://www.php.net/) >> >>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >> >>For additional commands, e-mail: php-general-help@lists.php.net >> >>To contact the list administrators, e-mail: php-list-admin@lists.php.net >> >> >> >> >> >> >> >>-- >> >>PHP General Mailing List (http://www.php.net/) >> >>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >> >>For additional commands, e-mail: php-general-help@lists.php.net >> >>To contact the list administrators, e-mail: php-list-admin@lists.php.net >> >------end of quote------ >> > >> > >> > >> >____________________________________________________________ >> >Cynic: >> > >> >A member of a group of ancient Greek philosophers who taught >> >that virtue constitutes happiness and that self control is >> >the essential part of virtue. >> > >> >cynic@mail.cz >> > >> > >> > >> >-- >> >PHP General Mailing List (http://www.php.net/) >> >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >> >For additional commands, e-mail: php-general-help@lists.php.net >> >To contact the list administrators, e-mail: php-list-admin@lists.php.net >> ------end of quote------ >> >> >> >> ____________________________________________________________ >> Cynic: >> >> A member of a group of ancient Greek philosophers who taught >> that virtue constitutes happiness and that self control is >> the essential part of virtue. >> >> cynic@mail.cz >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >> For additional commands, e-mail: php-general-help@lists.php.net >> To contact the list administrators, e-mail: php-list-admin@lists.php.net >> ------end of quote------ ____________________________________________________________ Cynic: A member of a group of ancient Greek philosophers who taught that virtue constitutes happiness and that self control is the essential part of virtue. cynic@mail.cz

« previous php.general (#32877) next »