<?php
class Foo{
function varr(){
$name='bar';
$this->$name;//调用Bar方法
}
function bar(){
echo 'i am a bar';
}
}
$foo=new Foo();
$funcname='varr';
$foo->$funcname();//调用varr方法--varr方法再调用bar方法,输出为 i ma a bar.
?>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号