Url method
<strong> $param = Array (); if ($ARGC > 1) { parse_str ($argv [1], $param); foreach ($param as $k = + $v) { echo "define $k = $v \ n"; $param [$k] = $v; }} Print_r ($param); Run the sample php sync_t_search.php "NAME=SJK&CITY=BJ" </strong>
System built-in variables
<strong>//There are significant limitations when multiple or multiple parameters are passed in $argv #0为当前执行的文件名 $argc #参数个数 </strong>
system function getopt
<STRONG>//1, Personal Summary: If only one parameter,: (Required)/:: (optional) can be//2, if the number of parameters to distinguish between optional required, it is recommended to use optional parameters and the following values do not pass the space//3, optional parameters: identifiers exist and have values, Subscript does not exist//4, required parameter: As long as the identifier exists, the subscript will exist (if not the value is False)/** * php song.php-h "a B" | | PHP song.php-h "A B" is not affected by whitespace (it is recommended to keep no spaces) array (1) { ["H"]=> string (3) "A B"} PHP song.php-h-aarray (1) { [" H "]=> string (2)"-A "} */var_dump (getopt (' h:a:: '));//required parameter, if there is a space between the participation in quotation marks, the option is followed by a blank space will not affect the value, will be the value of his back as the value of the parameter /**php Song.php-asongarray (1) { ["a"]=> string (4) "Song"} */var_dump (Getopt (' a::h: '));//Optional parameters, Parameter must be immediately following the option or not get </strong>
4. System function getopt
<strong>//standard output fwrite (STDOUT, "Enter your Name:"); echo "\ n";//Standard input $name = Trim (fgets (STDIN)); Fwrite (STDOUT, " Hello, $name! "); </strong>