Command line php has a linter (syntax checker) built into it.
php -l /path/to/file.php
Most PHP Integrated developer environments (IDE's) have a syntax checking built into it. The generally accepted best IDE for PHP is Jetbrains PHPStorm, but VSCode or Codium with the installation of https://intelephense.com/ plugin is a suitable free/low cost option. If you want to try it out, you should make sure to follow the installation instructions, which involves uninstaling a plugin that comes with vscode and will interfere with intelephense.
These tools do numerous things to show you what syntax errors you have.
Last but not least, there are numerous AI LLM's that you can point at the code and will diagnose problems.