How can I use the value of a variable as constant?

后端 未结 3 1153
花落未央
花落未央 2021-01-16 00:38
  1. I have a PHP site which uses language system based on \"define\" method. For example:

    define(\"_question_1\", \"How old are you?\");
    define(\"_quest         
    
    
            
3条回答
  •  孤独总比滥情好
    2021-01-16 01:07

    Try constant() it returns the value of a constant, for example:

    var_dump(constant('YourConstantNameHere'));
    

    or with variables

    var_dump(constant($a));
    

    http://www.php.net/manual/en/function.constant.php

提交回复
热议问题