Dynamic class method invocation in PHP

后端 未结 8 1991
感动是毒
感动是毒 2020-11-28 05:05

Is there a way to dynamically invoke a method in the same class for PHP? I don\'t have the syntax right, but I\'m looking to do something similar to this:

$t         


        
8条回答
  •  心在旅途
    2020-11-28 05:30

    Still valid after all these years! Make sure you trim $methodName if it is user defined content. I could not get $this->$methodName to work until I noticed it had a leading space.

提交回复
热议问题