【问题标题】:How can i call static php variable?我如何调用静态 php 变量?
【发布时间】:2018-10-16 02:33:09
【问题描述】:

我想知道如何在 之间插入 self::$tag,谢谢

我试过 但它不起作用。

<?php 
class model {
    public static $tag = "p" ;

    private static function surround($xx){
        return "<self::$tag>".$xx." </self::$tag>" ;
    }  //here is the problem    

    public static function label($xx){
        return self::surround("<label>".$xx."</label>") ;
    }
}
?>

【问题讨论】:

标签: php static-methods


【解决方案1】:

你很接近。只有字符串连接是错误的。 试试这个:

return "<".self::$tag.">".$xx." </".self::$tag.">" ;

【讨论】:

    猜你喜欢
    • 2017-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-25
    • 2010-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多