Fixing this took me years... I can't believe how long it took. The answers on stack overflow did not help.
The error was due to a mismatching php configuration for running in the shell ( /etc/php/8.1/cli/php.ini ) and in apache (/etc/php/8.1/apache2/php.ini ).
Specifically, I had to enable short tags for the shell:
short_open_tag = OnWith that, this particular error was fixed, and I was off to fixing the next error!
Added 2026-08-28: But also, I have changed my personal policy, to not use short tags in PHP at all. Not in Drupal. Maybe it makes sense with CakePHP, where you have the very elegant shorthand <?= $print_this_var; ?> This shorthand is just like ruby. It is equivalent to: <?php echo( $print_this_var ); ?> so you can see how the short open tag helps, and changes the syntax completely.
But that only makes sense if you use this kind of a template. In Drupal, the template is twig so it looks like this: {{ print_this_var }} I'm omiting a bunch of stuff, but you get the idea: there is no php open tag involved. Therefore, the short tag is not useful in Drupal. And in a page of code, the open tag takes up a whole line anyway, no need to save a few characters.
tl;dr: I abolished the short tags for php in drupal, I don't use them.
