What is going on here in PHP with classes?

前端 未结 3 506
眼角桃花
眼角桃花 2021-02-09 05:21

If I have this code, the string \"test\" is echoed. This is in PHP 5.3. Is this some oversight that shouldn\'t be relied on, or is it some way of achieving multiple inheritence

3条回答
  •  一向
    一向 (楼主)
    2021-02-09 06:11

    This has to be a bug. 100%.

    1. This is not inheritance.
    2. You should not be able to call Test1::getName() as getName() in Test1 is not static
    3. Even if you could call it, $this->name should not have access to the value in Test2.

    This breaks so many rules of OO I am seriously baffled how this got through testing. Well don for finding it!!

提交回复
热议问题