PHP: How to Get the Current Page URL
Sometimes, you might want to get the current page URL that is shown
in the browser URL window. For example if you want to let your visitors
submit a blog post to Digg you need to get that same exact URL. There
are plenty of other reasons as well. Here is how you can do that.
Add the following code to a page:
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
You can now get the current page URL using the line:
<?php
echo curPageURL();
?>
Sometimes it is needed to get the page name only. The following example
shows how to do it:
<?php
function curPageName() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
echo "The current page name is ".curPageName();
?>
Ïà¹ØÎĵµ£º
Àý×Ó. return() º¯ÊýµÄÓ÷¨
<?php
function square ($num)
{
return $num * $num;
}
echo square (4); // outputs '16'.
?>
º¯Êý²»ÄÜ·µ»Ø¶à¸öÖµ£¬µ«ÎªÁË»ñµÃ¼òµ¥µÄ½á¹û£¬¿ÉÒÔ·µ»ØÒ»¸öÁÐ±í¡£
Àý×Ó. ·µ»ØÒ»¸öÊý×éÒԵõ½¶à¸ö·µ»ØÖµ
<?php
function small_numbe ......
ÀàÎļþwordsplit.class.php£º
<?php
/********************************************************************
* DirCMSÖÐÎÄ·Ö´ÊÀà beta 1.0
* ---------------------------
* begin : 2010-5-11 beta 1.0
* update : 2 ......
Ê×ÏÈÎÒÃÇÒª½éÉÜÒ»ÏÂÎÒÃÇÔÚÕâÆªÎÄÕÂÖÐʹÓõÄPHPÀàLibchart£¬ÕâÊǸöÍâ¹úÈË£¨·ÇÖйú¹ú¼®µÄµØÇòÈË£¬±»³ÆÎªÍâ¹úÈË£¡£©Ð´µÄÃâ·ÑÀ࣡ʹÓÃÆðÀ´·Ç
³£¼òµ¥¡£¿´³öÀ´Á˰ɣ¬ÎÒÃÇÊÇÒªÓÃÒ»¸öÍâ¹úÈËдµÄPHP´´½¨Öù״ͼ£¬±ý״ͼ£¬ºÍÏßÐÔͼµÄÀ࣬À´¹¤×÷µÄ¡£Èç¹ûÄãҪѧϰÕâ¸öÀàµÄд·¨£¬ÄãÒ²¿ÉÒÔ°ÑÕâ¸öÀàÏÂÔØÏÂÀ´¿´¿´Íâ¹úÈ˵Ä˼·£¡
ÎÒÃÇ¿ªÊ¼°É ......
ÔÎĵØÖ·£º http://blog.csdn.net/lmss82/archive/2010/05/10/5574772.aspx
ÕâÊÇÒ»¸öÍêÕû¿ÉÓõĴúÂ룬²¿·Ö´úÂëÀ´×ÔÓÚÍøÂç¡£
PHP:
5.26
JS»·¾³£º
jquery.js,jquery_form.js
ʹÓò½Ö裺
¿ªÆôAPC.
ÏÂÔØphp_apc.dll£¬ÐÞ¸Äphp.iniÎļþÔö¼ÓÒÔÏÂÄÚÈÝ£º
extension=php_apc.dll
apc.rfc1867 = On
´úÂ룺
<?php
//< ......
Ò»£¬PHP½Å±¾´úÂë±ê¼Ç
PHPµÄ½Å±¾ÊÇÎļþÖÐÒ»¶ÔÌØÊâ±ê¼ÇËù°üÀ¨µÄÄÚÈÝ£¬ÈçASPÊÇ“<%....%>”,PHP¿É¿´³ÉÊÇ“<?...?>”¡£
È»¶øÎªÁËÊÊÓ¦XML±ê×¼ÒÔ½«PHPǶÈëµ½XML»òXHTMLÖУ¬PHP²»½¨ÒéʹÓö̸ñʽµÄ“<?...?>”£¬¶ø½¨ÒéʹÓó¤¸ñʽ±ê¼Ç“<?php...?>”
´ËÍâPHP´úÂ ......