Command Line PHP Displaying Code Instead of Output

If your PHP in a command line is not executing and just displays a source code, then be sure to check you are using proper opening tag:
<?php
instead just:
<?
or enable short_open_tag = On in your php.ini.

Source code is displayed instead of properly executing and printing output from PHP, if you use short tag and don’t have it allowed in your configuration file.

From documentation (php.ini) – short_open_tag must be On, if you want to use it:

; short_open_tag
; recommended for several years that you not use the short tag “short cut” and
; this short cut has been a feature for such a long time, it’s currently still
; http://php.net/short-open-tag
short_open_tag = On


Have a comment? Join discussion on Mastodon as a reply to: @dusoft@fosstodon.org