Hot search terms: 360 Security Guard Office365 360 browser WPS Office iQiyi Huawei Cloud Market Tencent Cloud Store
operating system Storage size: 1158720KB Time: 2014-04-22
Software Introduction: Ubuntu is a freely distributed and open source Linux-based operating system designed for humans, humans who have no previous experience with Linux...
Linux users often encounter php files. Faced with these php files, we sometimes use the command line to execute the php file to pass parameters. Today, the editor of Huajun will show you the steps to use the command line to execute PHP file parameter transfer in Linux system. I hope you can support and share the carefully selected content. If you like it, hurry up and get it! .

Specific steps:
To do a multi-language search index, the PHP program must execute the file through the PHP command in the Linux system, so the variables in the PHP program file cannot be obtained.
Therefore, parameters must be passed, but when executing PHP from the command line, Apache and other such things are not used. There is no http protocol. All get and post parameters will not work at all, and an error will be reported, as follows:
root@test:/pub/www/# php /pub/www/product/Crondo/makeindex.php? lang=en
Could not open input file: /pub/www/product/Crondo/makeindex.php? lang=en
You can get the parameters to be passed by getting the system environment variable $argv in the php execution file
1.test.php test file:
#! /usr/bin/php
"? php
print_r($argv);
echo "n";
echo “Total number of paramter is : “.$argc;
echo "n";
? 》
2. Command line call:
test@ubuntu:~/php$ php test.php 111 222 333 444
All param is:
Array
(
[0] =》 test.php //Parameter 0, the file name of the script itself
[1] =》 111//Parameter 1
[2] =》222//Parameter 2
[3] =》333//Parameter 3
[4] =》444//Parameter 4
)
Total number of paramter is: 5 //The value of $argc is the total number of parameters
This method of passing parameters is very similar to shell
test@ubuntu:~/shell$ sh test.sh 111 222
Two parameters 111 and 222 are passed to test.sh, and the shell will get three parameters. $0 is the file itself, $1 is parameter 1, and $2 is parameter 2. The difference is that php gets it in the form of an array, but the shell does not.
The above is the editor's summary of how to use the command line to execute PHP files to transfer parameters in Linux systems. Users who are not familiar with this operation should come and take a look. I believe that after reading this tutorial, you will have a better understanding of this operation.
How to customize symbols in coreldraw - How to customize symbols in coreldraw
How does coreldraw automatically adjust bitmaps - How does coreldraw automatically adjust bitmaps
How to print files in coreldraw - How to print files in coreldraw
How to embed bitmaps in coreldraw - How to embed bitmaps in coreldraw
How to draw a closed arc in coreldraw - How to draw a closed arc in coreldraw
Sohu video player
WPS Office
Tencent Video
Lightning simulator
MuMu emulator
iQiyi
Eggman Party
WPS Office 2023
Minecraft PCL2 Launcher
What to do if there is no sound after reinstalling the computer system - Driver Wizard Tutorial
How to switch accounts in WPS Office 2019-How to switch accounts in WPS Office 2019
How to clear the cache of Google Chrome - How to clear the cache of Google Chrome
How to practice typing with Kingsoft Typing Guide - How to practice typing with Kingsoft Typing Guide
How to upgrade the bootcamp driver? How to upgrade the bootcamp driver