[PHP] Function with Optional Arguments
Hi All, How do I write a function with optional arguments? Is it possible in php? function myfunc($First, $Second,[$Third, $Fourth]){ some stuff here } alex hogan * The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. *
Re: [PHP] Function with Optional Arguments
check this link simple example http://perl.about.com/library/weekly/aa121002c.htm On Wed, 21 Jul 2004 13:39:32 -0500, Alex Hogan [EMAIL PROTECTED] wrote: Hi All, How do I write a function with optional arguments? Is it possible in php? function myfunc($First, $Second,[$Third, $Fourth]){ some stuff here } alex hogan * The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function with Optional Arguments
Alex Hogan wrote: Hi All, How do I write a function with optional arguments? Is it possible in php? function myfunc($First, $Second,[$Third, $Fourth]){ some stuff here } Yes, it's in the manual, I recomend you read it first. function myfunc($First, $Second, $Third = 'third arguments default value', $Fourth = 'fourt arguments default value'){ some stuff here } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function with Optional Arguments
You can use default arguments: func foo($first, $second=2, $third=3 etc. or look at function func_num_args(... HIH Frank At 01:39 AM 7/22/2004, Alex Hogan wrote: Hi All, How do I write a function with optional arguments? Is it possible in php? function myfunc($First, $Second,[$Third, $Fourth]){ some stuff here } alex hogan * The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function with Optional Arguments
On Wed, 21 Jul 2004 13:39:32 -0500, Alex Hogan [EMAIL PROTECTED] wrote: Hi All, How do I write a function with optional arguments? Is it possible in php? function myfunc($First, $Second,[$Third, $Fourth]){ some stuff here } Give them a default value and they become optional function myfunc($First, $Second,$Third = 'something', $Fourth = 'something'){ some stuff here } If you want them empty, you can use $Third = '' or $Third = null depending on what you need. P.S. *WHY* do you include that outrageous footer? It serves absolutely no purpose. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php