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 |
|
#1
|
||||
|
||||
|
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?
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
|
|
|
|
#2
|
|||
|
|||
|
Re: optional arguments
You had it right on in your question:
function something($required, $optional='default', $optional2=NULL) { // DO SOMETHING }
__________________
Imagn Design: Los Angeles Web Design |
|
#3
|
||||
|
||||
|
Re: optional arguments
really? Didn't seem to work for me before. Hmmmm...... Works now, and very nicely. Wonder why......
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 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 |