How can php reflection get an attribute value prototype?

how can reflection get the prototype name instead of the value.
such as sample code, how do I get the value represented by "CRTINT" instead of CRTINT?
Thank you.

<?php 
echo "
";
define("CRTINT", "1120");
class test{
    public $age1 = CRTINT;
    private $age2 = array(CRTINT);
    protected $age3 = CRTINT * 87;
    protected $age4 = false;
}

$oReflectionClass = new ReflectionClass("test");
$props = array();
$allprops = $oReflectionClass->getDefaultProperties();
$getProperties = $oReflectionClass->getProperties();
foreach($getProperties AS $ps){
    $binds = array();
    $binds["getval"] = var_export($allprops[$ps->name],true);
    $props[$ps->name] = $binds;
}
print_r($props);
Php
Dec.28,2021

http://cn.php.net/manual/zh/m.

I wonder if this first rule is consistent with your situation


there is no way to get it.

in a class, you actually assign the value of a constant to a variable, and there is no constant information

.

you can use

get_defined_constants(true)['user']

get the user-defined constant and then judge based on the value

Menu