function myFunc( $number = 8 ) {
}
If client will pass a number to that function like myFunc( 11 ), then $number value will be 11. But if user will call it without argument or parameter, the $number variable will have value of
PHP Coding tips & tricks. Function & error explanation, coding style, how tos etc. Short notes posted directly from developer work environment.
PHP Coding Tips
Monday, August 20, 2012
PHP Function default parameter value
You can set default parameter value for method or function by giving it's initial value at argument declaration, see example:
Subscribe to:
Post Comments (Atom)
Great toutorial man! You saved my ass in this fuckin corporations work! Thanks.. :D
ReplyDeletePlease offer email subscription through feedburner.
ReplyDelete