开发者

Can names of private functions inside classes be repeated?

开发者 https://www.devze.com 2022-12-15 18:24 出处:网络
class On开发者_如何学Ce { private function thisfn() {} } class Two { private function thisfn() {} } is this legit? By the way, does it matter whether it\'s a private or public function inside a clas
class On开发者_如何学Ce
{
  private function thisfn()
  {}
}
class Two
{
  private function thisfn()
  {}
}

is this legit? By the way, does it matter whether it's a private or public function inside a class?

And also, can I create a new function named thisfn() outside of any class (and make it public)? like:

 function thisfn()
{}


This is legit as long as you don't redeclare the same method name within the same class.

Declaring a function outside the scope of the classes with the same name is also valid.

0

精彩评论

暂无评论...
验证码 换一张
取 消