How to interpolate constants?

Asked

Viewed 63 times

0

Why don’t these interpolations work and how to make them:

class Foo {
    const BAR = "baz";
}

define("TAZ", "qux");

echo "Foo::BAR={Foo::BAR} TAZ={TAZ}"; //Foo::BAR={Foo::BAR} TAZ={TAZ}
echo "Foo::BAR=${Foo::BAR} TAZ=${TAZ}"; //Foo::BAR= TAZ= e 2 NOTICE Undefined variable
echo "Foo::BAR={${Foo::BAR}} TAZ={${TAZ}}"; //Foo::BAR= TAZ= e 2 NOTICE Undefined variable

//Esperado:
echo "Foo::BAR=".Foo::BAR." TAZ=".TAZ; //Foo::BAR=baz TAZ=qux
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.