dongpin2969 2016-01-18 08:44
浏览 10
已采纳

如果函数具有相同的外部函数名称,它会调用什么?

Ex- I want to know the concept of OOP for undermentioned code.

class main()
{
    function out(){
                  function out(){
                   } // What this call?
    }
}
  • 写回答

1条回答 默认 最新

  • doucheng1063 2016-01-30 02:40
    关注

    i think what you were looking for is shadowing? there is no good answer as this has nothing to do with OOP and your example could have been better.

    overloading refers to same identifier different method signature

    function foo()
    function foo($param)
    

    overriding refers to a child class defining a method with the same signature as a method in the parent class.

    class parent {
        public function foo(){return 1;}
    }
    
    class child extends parent {
        public function foo(){return 2;}
    }
    

    shadowing refers to when an identifier in a lower scope has the same identifer as something in a higher scope.

    $var = 5;
    function foo($var){
        echo $var;
    }
    foo(6); // '6'
    echo $var; // '5'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突