This article mainly introduces the method of executing $argv and $argc in php scripts from the command line. This article introduces it to you in great detail. Friends who need it can refer to it.
It may be possible in actual work When you 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
Summary
The above is the method introduced by the editor to execute $argv and $argc in the php script from the command line. I hope it will be helpful to you. If you have any If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank you all for your support of the php Chinese website! Articles you may be interested in:thinkphp5 public methods for uploading images and generating thumbnails
The above is the detailed content of Command line execution $argv and $argc configuration method in php script_php example. For more information, please follow other related articles on the PHP Chinese website!