php伪静态的写法:首先打开编辑器;然后输入方法代码【$_GET[$Php2Html_TmpArray[0] = $Php2Html_TmpArray[1];print* g m &_r@ o a _ ` { :($_GET)】。
【相o E k ( 3 C T E %关学习推荐:
php伪静态的写法:
伪静态方法一
//
// localhost/php100/test.php?id|1@action|2
$Php2Html_FileUrl = $_SERVER["REQUEST_URI"];
echo $Php2Html_FileUrl."
";// /~ f J o h 3 hphp100/test.php?C _ Gid|1@action|2
$Php2Html_UrlString =n B h str_replaceF V u P("?. k l S O R","",str_replace("/", "", strrchr(strrchr($Ph} x C K R Tp2Html_FileUrl, "/"),"?")));
echo $Phpl @ T ~ I2Html_UrlString."
"d c ; k Q H % 6 r;// id|1@action|2
$Php2Html_UrlQueryStrList = explode("@", $Php2Html_Ut d 0 y hrlString);
print_r($Php2Html_UrlQueryStrList);// Array ( [0] => iq z % 8 ? P cd|1 [1] => action|2 )
echo "
";
foreach($PC V v M $ _ Php2Html_UrlQueryStrList as $Php2Html_UrlQueryStrv D / ` e % |)
{
$Php2Html_TmpArray = explode("|A e + ( U G #", $Php2Html_UrlQueryStr);
print_r($Php2Htm* ] = 5 Q 3l_TmpArray);// Array ( [0] => id [1] => 1 ) ; Array ( [0] => action [1] => 2 )
echo "
";
$_GET[$Php2Html_TmpArray[0] = $Php2Html_- [ 2TmpArray@ X q | x * B[1];
}
//echo '假静态:$_GET变量
';
print_r($_GET); // Array ( [id|1@action|2] => [id] => 1Q W 4 ; . # [ay ) 9 . ? / vction] => 2 )
echo "&B F %lt;br>";X D i t m / v a
ech/ O V = s 9 Uo "
";
echo $_GET[id]."
";// 1
echo $_GET[action];// 2
?>
伪静态方5 B } ] 5 ! w法二
//
// localhost/php100/test.php/1/2
$filename = basename(8 f B$_SERVER['SC, c # 7 = cRIPT_NAME']);
echo $_SERVER['SCRIPT_NAME']."
";// /php100/test.php
echo $filename."
";// test.php
if(strtolower($filen# 6 G k g name)=='tesE u @ b ^ x ( V Rt.php'){
if(!empty($_GET[id])){
$id=intval($_GET[id]);
echo $id."
";
$action=intval($_GET[action]);
echo $action."w M P j
";
}else{
$nav=$_SERVER['REQUEST_URI'];
echo "1:".$nav."
$script=$_SERVERv 6 F 2 R # | i[+ V S'SCRIPT_NAME'];
echo "2:".$script."
";// /php100/test.php
$nav=ereg_replace("^$script","",urldecode($nav));
echo $nav."
"; // /1/2
$vars=ex` k uplode("/",$nav);
print_r($vars);// Array ( [[ H Z } # p0] => [1] => 1 [2] => 2 ). 7 L
echo "
I e D ~ h , : = !";
$id=intval($E / R T p Vvars[1]);
$action=intval($varw s B h Qs[2]);
}
echo $id.'&'.$action;
}
?>
伪静态方法三
//
function mod_rewrite(){
global $_GET;
$nav=$_SERVER["REQUEST_URI"];
echo $nav."
";
$script_name=$_SERVER["SCRIPT_NAME"];
ecW 5 P F y j q 0 5ho $sc= L ^ 9ript_name."
";
$nav=substr(ereg_replace("^$script_name","",urldecode($nav))d O 0,1);
echo@ q M # C z $nav."&I d 7 2 f +lt;br>";
$nav=m { ` ppreg_replace("/^.ht(m){1}(l){0,1}h L g i$/","",$nav);//这句是去掉尾部的.html或.htm
echo $n( E k ] S v . p Nav."
";
$vars = expR : ]lode("/",$nav);
print_r($vars);
echo "
";
for($i=0;$i
$_GET["$vars[$i]"]=$vars+ N I : Y P p[$i+1];
}
return $_GET;
}
mod_rewrite();
$year=$_GET["year"];//结果为'2006'
echo $year."o $ q + P
";
$action=$_GET["action"];//结果为'_add'
echo $action;
?>
伪静态方法四
//
//利用server变量 取得PATH_INFO信息 该例中为Q [ { T G E /1,100,8630.html 也就是执行脚本名8 . ; o后面的部分
if(@$path_info =$_S^ M j j , 6 : 9ERVER["PATH_INFO"]){
//正则匹配一下参数
if(preg_match("/\/(\d+),(\d+),(\d+)\.html/si",$path_info,$arr_path)){
$gid =intval($arr_path[1]); //1 j _ + . Q A取得值 1
$sid =intval($arr_y b [ X S kpath[2]); //取得值100
$softid =intval($arr_path[3]); //取得值8630
}else die("Path:Error!");
//相当于soft.php?gid=1&sid=100&i I q S * $ ? Gamp;softid=8630
}e@ g c Y r ]lse die('Pa/ K -th:Nothing!');
?>
相关学习推荐:php编程(视频)
以上就是php伪静态的写法是什么的详细内容。