Call private methods and private properties from outside a class in PHP

前端 未结 8 1893
离开以前
离开以前 2020-12-15 18:21

I want to access private methods and variables from outside the classes in very rare specific cases.

I\'ve seen that this is not be possible although introspection

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 19:04

    Answer is put public to the method. Whatever trick you are going to do it wouldn't be understandable to fellow developers. For example they do not know that at some other code this function has been accessed as public by looking at the Demo class.

    One more thing. that console can access the first method writing a command like:. How can this even be possible? Console can not access demo class functions by using $this.

提交回复
热议问题