Php 动态变量的常数等价性

Php 动态变量的常数等价性,php,Php,我可以访问静态类变量,而无需使用危险的eval $aa = icon; echo StaticClass::chat{$aa}; equivalent is : constant("StaticClass::chat$aa") 然而,如果staticClass不是静态的,我不知道如何做同样的事情 i、 e需要访问 $StaticClass->get$aafunc(); // geticonfunc() 请帮忙 这个呢: <?php class test { publ

我可以访问静态类变量,而无需使用危险的eval

$aa = icon;
echo StaticClass::chat{$aa}; 

equivalent is :
constant("StaticClass::chat$aa")
然而,如果staticClass不是静态的,我不知道如何做同样的事情

i、 e需要访问

$StaticClass->get$aafunc(); // geticonfunc()
请帮忙

这个呢:

<?php

class test {
    public static $xyz = "static xyz content";

    public static function foo() {
        return "result of static foo function";
    }

    public $wxyz = "wxyz content";

    public function bar() {
        return "result of bar method";
    }
}

$xyzName  = "xyz";
$fooName  = "foo";
$wxyzName = "wxyz";
$barName  = "bar";

$instance = new test();

echo (test::$$xyzName)."<br />";
echo (test::$fooName())."<br />";
echo ($instance->$wxyzName)."<br />";
echo ($instance->$barName())."<br />";

?>

它返回:

static xyz content<br />
result of static foo function<br />
wxyz content<br />
result of bar method<br />
静态xyz内容
静态foo函数的结果
wxyz内容
条形图法的结果

使用谷歌“staticClass不是静态的”是什么意思?在更新的问题中,我看不出与常量有什么关系。我知道d函数常量,所以看起来与动态等价。你在问如何在方法名称位于变量中的对象上调用方法?!这是通过变量属性名访问静态属性,而不是常量(或更新中显示的方法)