Using PHP optional function parameters
August 4, 2008
/ Filed under: PHP, Code, Development, Tips
For a long time, I never knew why you'd want to set a functions' parameter equal to a value, in the function declaration:
Notice the parameter I used to ask myself, if There could be many reasons, but one such reason came to me recently. Since So why is an optional parameter useful? Well, for one thing, if you add an additional parameter to With optional parameters, you don't have to worry about that. You can add a bunch of new parameters to the function declaration, and as long as they are set to a value, your existing calls to
Comments/Mentions
|
Editor Picks
Email NewsletterSubscribe to the digest newsletter to receive posts by email: Recent Comments
Advertisements
|