PHP command line to write an instance of a shell command

Source: Internet
Author: User
Tags zend
This article to share the content is about the PHP command line to write the shell command instance, the content is very detailed, the need for friends can refer to, hope can help you.

PHP can run like Java Perl Python, and today I find that if I knew this early, maybe I wouldn't learn Java and Python.

That year to learn Java but in order to a program placed on the server, keep running and running, the original PHP can also.

php-husage:php [Options] [f] <file> [--] [args ...] php [options]-R <code> [--] [args ...] php [options] [-B <begin_code>]-R <code> [-e <end_code>] [--] [args ...] php [options] [-b <begin_code>]-F <fil e> [-e <end_code>] [--] [args ...] php [options]-S <addr>:<port> [-t docroot] [router] php [options] --[args ...] php [options]-a-a Run as interactive shell-c <path>|<file> look for php.ini file in this di  Rectory-n No configuration (INI) files would be a used-d Foo[=bar] Define INI entry foo with value ' bar '-e Generate Extended information for debugger/profiler-f <file> Parse and execute <file>. -H This help-i PHP information-l Syntax Check Only (lint)-M Show compiled in Modules-r <code> Run P HP <code> without using script tags <?..? >-B <begin_code> run PHP <begin_code> before processing input lines-r <code> run PHP <code> For Every input line-f <file> Parse and execute <file> for every input line-e <end_code> Run PHP <end _code> after processing all input lines-h Hide any passed arguments from external tools. -S <addr>:<port> Run with built-in Web server. -T <docroot> specify document root <docroot> for built-in Web server. -S Output HTML syntax highlighted source. -V Version number-w Output Source with stripped comments and whitespace. -Z <file> Load Zend extension <file>.   Args ... Arguments passed to script. Use--args when first argument starts With-or script was read from stdin--ini Show configuration file names--rf <name> Show information about function <name>. --RC <name> Show information about class <name>. --re <name> Show information about extension <name>. --rz <name> Show information about Zend extension <name>. --ri <name> Show Configuration for ExtEnsion <name>. 

1. Execute PHP scripts using the PHP command line, such as/usr/bin/php test.php

Abbreviationphp test.php

test.php

<?phpfor ($i =0; $i <10; $i + +) {echo $i; echo ' \ n ';}? >

2. The first line of the script is written on the #!/usr/bin/php, then the script can be set to execute chmod a+x test.php, then the script can be executed directly from the command line, for example./test.php

#!/usr/bin/php<?phpfor ($i =0; $i <10; $i + +) {echo $i; echo "java-er.com \ n";}? >

Execute an hour to see if PHP will hang, I hope a command line can run to the everlasting

#!/usr/bin/php<?phpfor ($i =0; $i <360; $i + +) {echo $i; sleep; echo "java-er.com \ n";}? >

3. External incoming parameters

#!/usr/bin/php<?php Var_dump ($ARGC); Returns the total number of parameters Var_dump ($ARGV); Exit;? >./test.phpint (1) Array (1) {[0]=> string (Ten) "./test.php"}./test.php a Java Phpint (4) Array (4) {[0]=> string (10 "./test.php" [1]=> string (1) "A" [2]=> string (4) "Java" [3]=> string (3) "PHP"}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.