Home  >  Q&A  >  body text

How to extract strings that do not meet the conditions in php

As shown in the picture:

QQ图片20201026150628.png

After the code in the picture is executed, the type of $result must be false. Because $a is not greater than $b.

The current requirement is that the value of $string is an expression filled in by the user (the format is irregular), and then I will judge whether the result of the expression he filled in is true. If the result is false, let the program tell the user the incorrect form output alone.

Just like the picture above, I want the program to output, because $a>$b is not true, so the result is false. How to achieve

echoecho1478 days ago1016

reply all(1)I'll reply

  • 灭绝师太

    灭绝师太2020-11-09 10:12:37

    Backend return json_encode(['status'=>0,'msg'=>'$a>$b is not established, so the result is false']); The front-end js receives and then alert() is given to the user. Enough.

    reply
    0
  • Cancelreply