Skip to main content
2 of 2
added 56 characters in body
Sampson
  • 268.8k
  • 76
  • 546
  • 570

PHP class function naming

I am having trouble with naming the function. I have a class and I need 2 functions something like below.

class myclass { public function tempclass () { echo "default"; } public function tempclass ( $text ) { echo $text; } } 

When I call

tempclass('testing'); // ( called after creating the object ) 

function tempclass() is being called how can i have 2 functions with same name but different parameters?

Abhishek Salian
  • 934
  • 2
  • 10
  • 27