开发者

Converting a string to a defined constant in PHP

开发者 https://www.devze.com 2023-04-09 09:26 出处:网络
Let\'s say I have defined the constant ERROR_0 as follows: define("ERROR_0","An error occurred.")

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消