3v4l.org

run code in 200+ PHP versions simultaneously
<?php class C { function k(){ return "k"; } function j(){ $a = $this->k(); return $this->$a(); } // assign k() to a variable function m(){ $a = "k"; $this->$a(); } // assign the name "k" to a variable }; $d = new C(); var_dump($d->j());
Output for 7.2.0 - 7.4.6
string(1) "k"