With some WordPress projects, you find yourself in the situation of designing your own templates. WordPress templates are the typical representatives of the old PHP school, according to which PHP is already its own template engine and therefore forms a hybrid of HTML and PHP instructions. This is more or less how PHP came about. Nowadays, PHP and HTML code are separated by additional template engines such as the oldie but goldie Smarty or Twig and Blade (Laravel), which makes sense for larger projects, especially for reasons of reusability and clarity of the project. Nevertheless, WordPress does not use template engines and leaves the separation of logic and presentation to the developer. Code expressions of the form are then created, for example:
"Unfortunately", however, the short version usually also works by replacing <?php with <?
Many Apache web servers will execute the code at this point. This is because in PHP.ini the configuration variable "short_open_tag" the value "On", which allows the execution of this syntax. However, it becomes problematic if the PHP version has the value "Off". At this point there will be a fatal error, e.g:
"PHP Parse error: syntax error, unexpected end of file in ..."
The problem with this is that many development environments, such as "MAMP", allow the short spelling by default. This can lead to nasty surprises on the hoster's production server - and anyone who often works with WordPress knows that debugging is not necessarily one of the strengths of this CMS.
Developers who use PHPStorm, for example, can check the "Short Open Tag Usage" option under Inspections > PHP > Code Style and then receive a corresponding warning during development:
Happy WordPress Coding!
Another note: You will most likely not see the error message on the screen, but instead a white screen of death will be displayed. However, you will find such a message somewhere in your hoster's error logs. Pay attention to the PHP files that you have modified or created.