Skip to content


A Brief Introduction of PHP-CLI

1. What is PHP-CLI ?

PHP-CLI is short for PHP Command Line Interface. As meaning of its name, it is the environment that php runs on command line. It’s widely known that php is an server side language that provide dynamic pages. But in fact,  php can do anything including shell scripting and even GUI programs and so on. A famous chinese dynamic dns provider has a third-party client soft wrriten in php. So if you known php well, you can write any kind of applications of your interest. And php-cli can help you write command line applications.

2. What’s the Syntax of this PHP-CLI

Of cource the syntax of php because it’s name if PHP-CLI !

3. How to run this PHP-CLI script?

It’s very easy. To run php in the command line:

kangjia@localhost # /usr/bin/php -r “echo ‘hello php!’;”

To run a php script file:

kangjia@localhost # /usr/php/php -f hello.php

if the /usr/php/php is in the system environment, you can simply use “./hello.php”.

PS: In PHP-CLI, there is no limit for extensions. They can be ‘php’, ‘php-cli’ and any word you want.

4.  Advantages of PHP-CLI

  1. PHP is a widely used language. If you are familiar with php, you can write shell progarams immediately.
  2. Lots of PHP functions is available.
  3. Cron jobs are also available.

5. Conclusion

So this is the brief introduction of PHP-CLI, a command line interface of PHP. Any problem, just leave me a message.

Posted in php script.

Tagged with , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.