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:
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:
; 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
short_open_tag = On