Question: I'm trying to access a class constant in one of my classes:

```
const MY_CONST = "value";

```

If I have a variable which holds the name of this constant like this:

```
$myVar = "MY_CONST";

```

Can I access the value of MY\_CONST somehow?

```
self::$myVar

```

does not work obviously because it is for static properties.
Variable variables does not work either.

Answer: 
Just a note for Reflection: the constructor for ReflectionClass must receive the **full path** of the class for its parameter. 
This means that just setting the string 'A' as a constructor parameter may not work in some cases.

To avoid this problem, when using ReflectionClass you will be better if you do this:

```
$classA = new A();
$name_classA = get_class($classA);
$ref = new ReflectionClass(get_class($name_classA));
$constName = 'MY_CONST';
echo $ref->getConstant($constName);

```

Function get\_class will give you the full path of a class whenever you are in the code. Missing the full path may result in a "Class not found" PHP error.
have you tried 

```
$myVar = MY_CONST or $myVar = $MY_CONST

```