易截截图软件、单文件、免安装、纯绿色、仅160KB

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();
?>


相关文档:

GyPSii API PHP请求示例

根据GyPSii API提供的操作类和方法,发现请求会失败,返回的是一个bed request。原因其实很简单,但一直没有找到,最终原因是对方提供的host是错误的,没天理。
对方提供的host和uri:
host:http://dev3.gypsii.com/gypsii
uri:http://dev3.gypsii.com/gypsii/xmlservice.cgi
这个host就是错的,应该是:dev3.gypsii.co ......

无兄弟,不编程 顶兄弟连PHP学院

         真兄弟,讲义气,同甘苦,共进退。
        《兄弟连》电影的上映,大家纷纷给出了好评。不就是一部战争片么,为何有如此强烈的响应?首先这是一部战争片并没错,但《兄弟连》电影更多的是洋溢着那种相濡以沫的兄弟情义,坚如磐石。多 ......

PHP分割textarea转回的数据

假如一个textarea中有N多行的数据,要将它转为PHP的一维数组,
 <form id="textarea_test" action="textarea.php" method="post">
<textarea cols="50" rows="5" name="aa" id="abc" >

<?php
$str = $_POST['aa'];
//var_dump($str);
//$str = "chenjinle le";
$array = explode("\n", trim($ ......

获得php所对应的配置文件(php.ini)信息

[root@BIND9-master /usr/local/bin]# php --ini
Configuration File (php.ini) Path: /usr/local/etc
Loaded Configuration File:         /usr/local/Zend/etc/php.ini
Scan for additional .ini files in: /usr/local/etc/php
Additional .ini files parsed:  &n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号