Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert String value into Constant

Tags:

variables

php

I have defined a Constant,

define("TEST", "good");

now I have $post = "TEST";

I just wanted to convert this "test" as an constant.

e.g: echo $post; it should print good

like image 846
GoSmash Avatar asked Jan 16 '23 20:01

GoSmash


1 Answers

echo constant($post);

http://php.net/constant

like image 85
deceze Avatar answered Jan 25 '23 14:01

deceze