jaymc Posted November 22, 2008 Share Posted November 22, 2008 Lets say I have a function set out like this function beans($a,$b) { // DO STUFF } I have used this 100's of times in various scripts.. however, I now need to change this function to look like function beans($a,$b,$c) { // DO STUFF } Is there a way to call the function like beans($a,$b) or beans($a,$b,$c) so that if $c is not used it is simple ignored, as apposed to javascript giving an error I do not want to change all occurances of this function if I do not have to Thank you! Link to comment https://forums.phpfreaks.com/topic/133796-add-variable-into-function/ Share on other sites More sharing options...
jaymc Posted November 22, 2008 Author Share Posted November 22, 2008 PHP does it like this function myFunction($mandatory_argument,$optional_argument = 1) { /* ...Whatever... */ } Link to comment https://forums.phpfreaks.com/topic/133796-add-variable-into-function/#findComment-696359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.