PHP CLI mode in a detailed

Source: Internet
Author: User
Tags php cli vars

* PHP CLI mode
* Cli:command lines Interface (command line interface)
* PHP can be used in addition to the Apache IIS server, can also be run through the CLI mode, because PHP is essentially written in C language program
* The following are common PHP CLI commands

* in console input OH:

Php-v Show PHP version

--ini output php.ini configuration file information

--rf function <name> output PHP functions, including parameters of functions

--ri <extension> output PHP extension information

-I output PHP details, a lot of content, equivalent to Phpinfo ();

-m output compiled module

--re output PHP extension information, package block the corresponding function of this module, the constants defined in this extension

Run the PHP program in CLI mode

Create a new cli.php file

The first line is entered:

#! C:\php\php.exe-q

This command indicates that this is a CLI program

After entering PHP tags

<?php

echo "Hello php cli";

?>

Then enter Php.exe cli.php in the command line mode

The complete program is as follows

[PHP]View PlainCopy print?
    1. #! C:\php\php.exe-q
    2. <?php
    3. echo ' Hello php cli ';
    4. ?>

Using the CLI method to transmit the parameter

PHP passes parameters via $_server[' argc ' and $_server[' argc ']

The passed parameter is daiyutage 22

[PHP]View PlainCopyprint?
    1. #! C:\php\php.exe-q
    2. <?php
    3. echo "Hello php cli\n";
    4. Var_dump ($_server[' argc '); //$_server[' argc ') is the number of arguments passed
    5. Var_dump ($_server[' argv '); //s_server[' argv ') is the value of the passed parameter, expressed as an array
    6. ?>

Note: When the Apache server passes the Web page to the PHP interpreter for data submitted to the server, it is passed through environment variables, and some PHP default global variables are initialized after the PHP process is started.

After running the environment, the system gives the PHP global variables to be set, all PHP can be used directly.

Source: http://blog.csdn.net/daiyutage/article/details/48999129

PHP CLI mode in a detailed

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.