PHP CLI – Command Line Interface

If you have installed PHP, you probably have the PHP CLI as well. CLI allows you to run PHP scripts from the command line, without a browser or the definition of a virtual site. You can use it to define a Cron Job or a scheduled task, without learning PERL or other scripting languages. In linux, all you have to do is to put the following first line in your file:

  #!/usr/bin/php

or

  #!/usr/bin/env  php

if the path to ‘php’ is ‘/usr/bin/php’ or the path to ‘env’ is ‘/usr/bin/env’.

You should make your PHP script executable as well.

Superglobals are still defined, but this time are empty hashes, i.e. $_GET[“anyname”] will hold the value null.

 

Advertisements

One thought on “PHP CLI – Command Line Interface

Comments are closed.