Can I use string concatenation to define a class CONST in PHP?

前端 未结 5 1646
一个人的身影
一个人的身影 2020-11-30 09:54

I know that you can create global constants in terms of each other using string concatenation:

define(\'FOO\', \'foo\');
define(\'BAR\', FOO.\'bar\');  
echo         


        
5条回答
  •  眼角桃花
    2020-11-30 09:59

    Always fall back to the trusty manual for stuff like this.

    Regarding constants:

    The value must be a constant expression, not (for example) a variable, a property, a result of a mathematical operation, or a function call.

    So... "no" would be the answer :D

提交回复
热议问题