chiprivers Posted November 26, 2006 Share Posted November 26, 2006 Is it possible to create a function with an optional varable such as:function doThis($x) {blah blah}But where specifying $x is optional. Then how do I check to see if $x is declared and get an alternative value if not? Link to comment https://forums.phpfreaks.com/topic/28551-function/ Share on other sites More sharing options...
jwk811 Posted November 26, 2006 Share Posted November 26, 2006 you could just set $x = "" or null Link to comment https://forums.phpfreaks.com/topic/28551-function/#findComment-130630 Share on other sites More sharing options...
wildteen88 Posted November 27, 2006 Share Posted November 27, 2006 The only way to make an optional variable (parameter) for a function is to provide a default value if that parameter is not passed to the function when called. Link to comment https://forums.phpfreaks.com/topic/28551-function/#findComment-131081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.