This article mainly introduces the methods of $argv and $argc in command line execution of php scripts. This article introduces you to it in great detail. Friends who need it can refer to it. I hope it can help you.
In actual work, you may encounter the need to execute a php script on the nginx command line. Of course, you can configure a conf for external network access.
Use
php index.php
<?php echo $argv[0]; echo "\n"; var_dump($argv[1]); echo "\n"; var_dump(intval($argv[2])); echo "\n"; echo $argv[3]; echo "\n"; echo $argc;
php index.php 1 10 100
index.php //$argv[0]显示结果 经测试此处显示的是此脚本相对于执行位置的相对路径(就是你在哪里输入的php index.php,这里显示的就是 index.php 相对于你当前目录的位置) string(1) "1" //$argv[1]显示第一个参数会转为字符串 int(10) //$argv[2]显示第二个参数 100 //$argv[3]显示第二个参数 4 //$argv参数的个数 相对路径+你传的参数
$avgv is the argument vector, $avgc is the argument count
$argv and $argc in php_PHP tutorial
Command line variables can be used in php--$argv and $argc
The above is the detailed content of $argv and $argc configuration methods in php script. For more information, please follow other related articles on the PHP Chinese website!