0

Is there in php something like this? If not, what is the best approach here?

parse_bool("1 > 2"); //returns false
parse_bool("'a' == 'a'"); // returns true
user3325976
  • 799
  • 1
  • 6
  • 16

1 Answers1

1

You can use eval for this purpose.

However, it's extremely important to be aware of the potential risks involved, especially if you're parsing any form of user provided input. See the existing When is eval evil in php? question/answers for more information.

Community
  • 1
  • 1
John Parker
  • 54,048
  • 11
  • 129
  • 129