This is a discussion on "optional arguments" within the PHP Forum section. This forum, and the thread "optional arguments are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
optional arguments
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
||||
|
optional arguments
Quite a lot of programming languages have optional arguments in functions. In some, you simply put myvar = 'default' in the argument list, and myvar will equal default if not defined. In other languages you redefine the function, one with and one without the optional argument. Does PHP have something like this?
__________________
echo "Take it easy, ".$CloudedVision; .links { site: other-road-design; blog: only-nerds-allowed; project: resource-fish; organization: ARMIES6; } <quote>"I think it's wrong that only one company makes the game Monopoly" - <name>Steven Wright</name></quote>
Last Blog Entry: More Cheat Sheets (Jul 12th, 2008)
|
|
|
|
|||
|
Re: optional arguments
You had it right on in your question:
function something($required, $optional='default', $optional2=NULL) { // DO SOMETHING } |
|
||||
|
Re: optional arguments
really? Didn't seem to work for me before. Hmmmm...... Works now, and very nicely. Wonder why......
__________________
echo "Take it easy, ".$CloudedVision; .links { site: other-road-design; blog: only-nerds-allowed; project: resource-fish; organization: ARMIES6; } <quote>"I think it's wrong that only one company makes the game Monopoly" - <name>Steven Wright</name></quote>
Last Blog Entry: More Cheat Sheets (Jul 12th, 2008)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| All Websites are Arguments (article) | brockomundo | Webforumz Cafe | 2 | Jul 8th, 2007 12:31 |