I want to use a constant in PHP, but I also want to put it inside double quotes like a variable. Is this at all possible?
define(\"TESTER\", \"World!\");
ech
Alternatively, do
"this is " . MY_CONSTANT
or
"this is " . constant("MY_CONSTANT");
I've found that when dot-concatenation of a constant is a problem, using sprintf to get my string is usually the way I want to go in the end.
Concatenation is the way to go.
Unless you want the hokey, nasty, inefficient, evil monkey way of:
echo preg_replace("/TESTER/",TESTER,$original_content);
I recomend you to use concatenation because:
Sorry, that's not the way constants in PHP work. You can put variables in double quotes and heredocs but not constants.
no way, unless you write your own string parsing function