Converting a string to a defined constant in PHP
Let's say I have defined the constant ERROR_0
as follows:
define("ERROR_0","An error occurred.")
Now, let's say I have the string "ERROR_0" but I want to convert that i开发者_开发技巧nto the constant ERROR_0
such that I can get the string "An Error occurred." How can I do that?
Thanks!
Use constant
function
echo constant("ERROR_0");
精彩评论