How can syntax errors in PHP scripts be differentiated from semantic errors?

Syntax errors in PHP scripts are typically detected by the PHP parser during the compilation phase due to incorrect syntax or structure in the code. These errors are usually related to missing or misplaced punctuation, incorrect variable names, or using undefined functions. On the other hand, semantic errors occur when the code is syntactically correct but does not produce the intended outcome due to logical errors in the code.

// Syntax error example
$variable = 5
echo $variable;

// Semantic error example
$number1 = 10;
$number2 = 20;
$result = $number1 * $number2;
echo "The result is: " . $result;