YourNameHere Posted January 21, 2010 Share Posted January 21, 2010 How would a make a function that "CAN" take 4 params but make 2 optional. In some of the language construct functions I see it is possible. but I get an error when I do it with a homemade function. for example: mysql_error(); will take two params but you can omit the $link identifier. Link to comment https://forums.phpfreaks.com/topic/189278-making-a-parameter-in-a-function-optional/ Share on other sites More sharing options...
Mchl Posted January 21, 2010 Share Posted January 21, 2010 function func($v1,$v2,$v3 = null, $v4 = null) { ... } Link to comment https://forums.phpfreaks.com/topic/189278-making-a-parameter-in-a-function-optional/#findComment-999232 Share on other sites More sharing options...
YourNameHere Posted January 21, 2010 Author Share Posted January 21, 2010 function func($v1,$v2,$v3 = null, $v4 = null) { ... } Awesome thank you! Link to comment https://forums.phpfreaks.com/topic/189278-making-a-parameter-in-a-function-optional/#findComment-999233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.