Home >Backend Development >PHP Tutorial >cmd run php_PHP tutorial
Open command prompt cmd.exe
E:wampbinphpphp5.2.6>php.exe a.php 11
11 is to pass parameters
Obtain
if($argv[1]){
$_GET['id']=$argv[1];
}
echo $id=$_GET[id]+1;
You can change a.php to your file name, pay attention to the directory structure
I use a.php directly here because a.php and php.exe are in the same directory
For convenience, you can also add the php installation directory to the environment variable PATH
(Right-click My Computer->Properties->Advanced->Environment Variables, if PATH exists, add your PHP installation directory to the original PATH, if it does not exist, create a new PATH)
After adding it to the environment variable, you don’t need to enter the php installation directory in cmd
Enter php.exe "a.php" (note that "a.php" must be in the directory where your cmd is at this time)