A Command Line Interface Server Application Programming Interface (CLI SAPI) has existed for PHP since v4.2, but only with the release of 4.3 did it come to maturity. In PHP 5 it is built automatically, and can be configured to be installed automatically also. Although you can use the code given here in previous versions of PHP, you may encounter problems with versions prior to PHP 4.3.
Want to learn PHP 7?
Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!
If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!