![]() |
Optional function parameters?
How would you create optional function/method parameters in php? I want to do them like the default functions. Like, mysql_query() has a string for the first part, and an optional link identifier after it.
|
Just provide a default value within the function signature:
PHP Code:
|
Cool, and just because I don't want to make another topic, should I get into the habit of unsetting my variables and objects?
|
That depends entirely on who you talk to. Generally there is no need to unset variables unless keeping them around is particularly expensive. For example, if you loaded a huge XML document (talking tens/hundreds of megabytes), images (GD), etc. into your script.
Just like the common advice is to close any open database connections (and free results) as soon as you're finished with them, it's a good idea to tidy up a bit but don't go over the top by unsetting everything. |
| All times are GMT. The time now is 05:52 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0