What are the potential challenges of parsing mathematical expressions in PHP?

One potential challenge of parsing mathematical expressions in PHP is handling operator precedence and associativity correctly. This involves ensuring that operations are performed in the correct order according to mathematical rules. One way to solve this issue is by using a parser that follows the rules of operator precedence and associativity.

// Example code snippet using the eval() function to parse a mathematical expression
$expression = "3 + 5 * 2";
$result = eval("return $expression;");
echo $result; // Output: 13