如何为数组内的值创建常量并在php中的类外部访问它们

I have created array inside a class using constant and assigned values to that array by key,value pair so I want to create const for a,const for b,const for c values, so how to create this and access those values(a,b,c) outside class using Php? actually I am not getting any output for this.

<?php  

class foo {

    const arrayOfvalues = [
        'a' => 'text for  a',
        'b' => 'text for b',
        'c' => 'text for c'

    ]; 
    const for_avalue= foo::arrayOfvalues[0];  //create constant for a
    const for_bvalue= foo::arrayOfvalues[0];  //create constant for b
    const for_cvalue= foo::arrayOfvalues[0];  //create constant for c

}
echo 'current const value'. for_avalue;  //call a value by its constant name

?>

You forgot to use the correct indexes and also to call the class. Although I don't understand why you want to create constants in this way, here comes the correct version of your current code:

class foo {

    const arrayOfvalues = [
        'a' => 'text for  a',
        'b' => 'text for b',
        'c' => 'text for c'

    ]; 
    const for_avalue= foo::arrayOfvalues['a'];  //create constant for a
    const for_bvalue= foo::arrayOfvalues['b'];  //create constant for b
    const for_cvalue= foo::arrayOfvalues['c'];  //create constant for c

}
echo 'current const value'. foo::for_avalue;