简体   繁体   English

我怎样才能称呼静态php变量?

[英]How can i call static php variable?

i want to know how to insert : self::$tag between <> , thanks 我想知道如何在<>之间插入:self :: $ tag,谢谢

i tried <{self::$tag}> but it does not function . 我尝试了<{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>") ;
    }
}
?>

You are close. 你近了 Only the string concatenation is wrong. 仅字符串连接是错误的。 Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM