You are here: Re: question about functions and variables « All PHP « IT news, forums, messages
Re: question about functions and variables

Posted by Oli Filth on 09/16/05 20:37

matt said the following on 16/09/2005 18:10:
> I made function that inputs 3 variables and outputs 1. I modified it to
> accept 4 variables. Most of the time, it will use the old method of 3
> variable input, but occasionally it will need that 4th var. is there a way
> to leave the code that calls the function in place, and add the ability to
> use a function w/ 4 variables? right now, it gives me a warning that the
> variable is not sent. I'd like to shy away from suppressing warnings. I'm
> using php 4.3
>

function foo($a, $b, $c, $d = DEFAULT_VALUE)
{



}


where DEFAULT_VALUE is whatever you want the value of $d to be when
foo() is called with only 3 arguments.

Now, calling:

foo(1, 2, 3);

is the same as calling:

foo(1, 2, 3, DEFAULT_VALUE);


--
Oli

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация