½ñÌiд±i°×ǽʱºoµÄµ¼º½ÅжÏÓoµ½µÄÕa¸oÎÊÌa¡£ÎҵĽa¾o˼Â*ÊÇÕaÑu£º
Åжϵ±Ç°µÄphpÎļþÃuÀ´È*¶¨µ¼º½ÌoµÄÄÄ¿e¸ßÁÁ¡£
ÄÇphpÈçºÎ»ñÈ¡µ±Ç°µÄurlÎļþÃuÄØ£¿
ÎÒÊÇÕaÑu´¦ÀiµÄ :shock:
½Ì³Ì
Ê×Ïȿ϶¨ÊÇÒª»ñÈ¡µ±Ç°Ò³ÃaeURLµÄ£¬ÔÚÕaÀiÎÒÃÇʹÓÃphpµÄ$_SERVER['PHP_SELF']
À´»ñÈ¡»ñÈ¡ÍøÒ³µØÖ*
¼ÙÉeurlΪ http://www.jb51.net/index.php
$php_Self= $_SERVER['PHP_SELF']; //»ñÈ¡ÍøÒ³µØÖ*
//Êa³o½a¹u£ºhttp://www.jb51.net/index.php
Êa³oºo¢ÏÖ£¬ÎÒÃÇÖ»ÐeÒªindex.php£¬Ç°ÃaeÒ»´o´®¶«Î÷¶¼ÊÇûÓõġ£
Ôoô°iÄØ£¿
ÕaÀiÎÒÃǾÍÓõ½ÁËsubstr()º¯Êý¡£
substr()
ÊÇÓÃÀ´µ»Ø×Öu´®µÄÒ»²¿Ö£º
*substrÓi¨**
substr(string,start,length)
²ÎÊý ÃeÊo
string ±ØÐe¡£¹ae¶¨Òªµ»ØÆaÖÐÒ»²¿ÖµÄ×Ö*u´®¡£
start
±ØÐe¡£¹ae¶¨ÔÚ×Ö*u´®µÄºÎ´¦¿ªÊ¼¡£
length
¿ÉÑ¡¡£¹ae¶¨±»µ»Ø×Öu´®µÄ³¤¶È¡£Ä¬ÈÏÊÇÖ±µ½×Ö*u´®µÄ½aβ¡£
¿´µ½Õa¸oº¯ÊýµÄµÚ¶þ¸o²ÎÊý£¬¹ae¶¨ÔÚ×Ö*u´®µÄºÎ´¦¿ªÊ¼¡£ºÜÏÔÈ»ÊÇÔÚurlÖеÄ×iºoÒ»¸o/¿ªÊ¼²ÅÊÇÎÒÃÇËuÐeÒªµÄ¡£
ÓÚÊÇÎÒÃÇÓÖÐeÒªÓõ½strrpos()
º¯ÊýÀ´È¡µÃ/×iºoÒ»´Î³oÏÖµÄλÖá£
*strrposÓi¨**
strrpos(string,find,start)
²ÎÊý ÃeÊo
string ±ØÐe¡£¹ae¶¨±»ËÑË÷µÄ×Ö*u´®¡£
find ±ØÐe¡£¹ae¶¨Òª²eÕÒµÄ×Ö*u¡£
start ¿ÉÑ¡¡£¹ae¶¨Ôںδ¦¿ªÊ¼ËÑË÷¡£
ËuÒÔ×Ü´uÂeÈçÏ£º
$php_Self = substr($_SERVER['PHP_SELF'],strripos($_SERVER['PHP_SELF'],"/")+1);
//ΪɶҪ¼Ó1ÄØ£¿ÒoΪҪÅųýÇ°ÃaeµÄÄǸo /
±È½ÏÍƼoµÄÒ»¸oº¯Êý
//»ñµÃµ±Ç°µÄ½Å±¾ÍøÖ*
function GetCurUrl()
{
if(!empty($_SERVER["REQUEST_URI"]))
{
$scriptName = $_SERVER["REQUEST_URI"];
$nowurl = $scriptName;
} else
{
$scriptName = $_SERVER["PHP_SELF"];
if(empty($_SERVER["QUERY_STRING"]))
{
$nowurl = $scriptName;
} else
{
$nowurl = $scriptName."?".$_SERVER["QUERY_STRING"];
}
}
return $nowurl;
}
Èç¹u¸Ð¾oÉÏÃaeµÄÎÄÕ²»¹»Ï¸£¬½¨Òe´o¼Ò¿´ÕaƪÎÄÕ£ºhttp://www.jb51.net/article/22056.htm
ÕaÑu¾Í½a¾oÁË£¬ºÜ¶aÇe¿o϶¼ÊÇÐeÒªÒ»Ð(C)×Ö*u´®½ØÈ¡º¯ÊýµÄ°iÖu²Å¿ÉÒԵõ½ÎÒÃÇÏeÒªµÄ½a¹u¡£