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: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

2 comments:

  1. Great toutorial man! You saved my ass in this fuckin corporations work! Thanks.. :D

    ReplyDelete
  2. Please offer email subscription through feedburner.

    ReplyDelete