Linux users often encounter php files. In the face of these php files, we sometimes use the command line to execute php files for parameter transfer. But how do you do this? Today, Xiaobian will explain to you how to execute php files through the command line in the Linux system.
specific steps:
do multilingual search index, but php program to be executed by the file system of Linux command in php, php files so the variables can not be Obtain.
So to pass the parameters, but the command line to execute php, is not going to Apache and other such things, there is no http protocol, all get, post pass parameters do not work at all, and 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 executable file
1.test.php test file:
#! /usr/bin/php
"? Php
print_r($argv);
echo “\ ”;
echo “Total number of paramter is : “.$argc;
echo “\ ”;
?
2. Command line call:
test@ubuntu:~/php$ php test.php 111 222 333 444
All param is :
Array
(
[0] =》 test.php //Parameter 0, file name of the script itself
[1] =》 111//parameter 1< Br>
[2] =》 222//parameter 2
[3] =》 333//parameter 3
[4] =" 444//parameter 4
)
Total number of paramter is : 5 //$argc is the total number of arguments
This way of passing arguments is very similar to the shell
test @ubuntu:~/shell$ sh test.sh 111 222
Two parameters 111,222 are passed to test.sh, the shell will get three parameters, $0 for the file itself, $1 for parameter 1, $2 For the parameter 2. The difference is that php gets in the form of an array, and the shell is not
The above is the method of using the command line to execute the php file in the Linux system, and it will not be used. Let's take a look at it, I believe that after reading this tutorial, it will make you more comfortable with this operation. Solution.
Linux system operation, sometimes need to install the kernel header file when installing the device
We all know that the ls command is mainly used to display the contents of the curre
In Linux system operation, if you need to use the terminal for some reasons, how to
The ssh connection server in the Linux system will have an automatic interrupt time
Linux system how to build ldap server
How to find the reset user name and password in the Uuntu system
Ubuntu installs AMD proprietary driver steps
The usage of the hostname command under Linux is
The implementation principle of Linux system TSO
Linux installation of MariaDB database through Yum
Linux system iptables error iptables: Protocol wrong how to do?
What should I do if the Linux system Git cannot exit completely (exit code 128 or 1)?
How to install Autossh on Linux system
How to turn off recovery mode in Ubuntu 12.04 system
Ubuntu vi using the arrow keys error how to solve?
Linux how to use the umount command to force the file system to be unmounted
Detailed description of win 7 system backup operation
Resolve access to Windows 2008 shared resources error
Share win2003 prohibits remote login tips
Ingeniously solve the Win7 system restore property page error trick
How to delete OneDrive in Win10 system? How to delete OneDrive in Win10 system
Solve the Win7 taskbar power icon does not display