someguy321 Posted November 15, 2010 Share Posted November 15, 2010 If I have a parameter that has a default value, how do I pass nothing such that it uses the default value? Passing NULL does not work. function test($to = "test@test.com", $from) { echo $to . "<BR>" . $from; } //This will NOT show "test@test.com" but instead an empty line test( NULL, "fake@fake.com" ); Quote Link to comment https://forums.phpfreaks.com/topic/218773-how-pass-empty-or-nothing-to-a-default-parameter-for-a-function/ Share on other sites More sharing options...
mikosiko Posted November 15, 2010 Share Posted November 15, 2010 Examples #3 and #4... pay special attention to note before example #5 and then #6 http://php.net/manual/en/functions.arguments.php Quote Link to comment https://forums.phpfreaks.com/topic/218773-how-pass-empty-or-nothing-to-a-default-parameter-for-a-function/#findComment-1134651 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.