What is the usage of argv in php

WBOY
Release: 2023-03-15 17:12:01
Original
3161 people have browsed it

In PHP, "$argv" is used to store parameters pointing to strings. It is an array of parameters passed to the script. Each element points to a parameter. The first parameter is always the file name of the current script; " $argv" is defined in the "$_SERVER" global array and is only available when "register_argc_argv" is turned on.

What is the usage of argv in php

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.

What is the usage of argv in php

$argv - parameter array passed to the script

String array, used to store an array of pointers pointing to your string parameters , each element points to a parameter

Description

An array containing the parameters passed to the current script when run from the command line.

Note:

The first parameter is always the file name of the current script, so $argv[0] is the script file name.

This variable is only available when register_argc_argv is turned on.

$argv—This is defined in the $_SERVER global array (when the script is run in command line mode, the argv variable is passed to the program as C-style command line arguments).

What is the usage of argv in php

The example is as follows:

<?php
var_dump($argv);
?>
Copy after login

When using this command to execute: php script.php arg1 arg2 arg3

The output of the above routine is similar In:

array(4) {
  [0]=>
  string(10) "script.php"
  [1]=>
  string(4) "arg1"
  [2]=>
  string(4) "arg2"
  [3]=>
  string(4) "arg3"
}
Copy after login

Recommended study: "PHP Video Tutorial"

The above is the detailed content of What is the usage of argv in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template