易截截图软件、单文件、免安装、纯绿色、仅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();
?>


相关文档:

PHP教程 初学者必看的PHP代码


经典循环例子
<HTML>
<HEAD>
<TITLE>经典循环例子</TITLE>
</HEAD>
<BODY>
<?
    for($counter = 1; $counter <= 6; $counter++) 
      //循环6次
    {
        print("<B& ......

PHP中session_register函数详解


语法: boolean session_register(string name);
注册新的变量。
返回值: 布尔值
函数种类: 资料处理
内容说明
本函数在全域变量中增加一个变量到目前的 Session 之中。参数 name 即为欲加入的变量名。成功则返回 true 值。
假如在头文件,开启session,即使用session_start()函数后面加上session_register(string na ......

PHP调用系统命令修改IP,netmask,gateway,mac,dns

ip_contrl.php:
<?php
 //include('header.php');
 
 $ipaddr = $_POST['ipaddr'];
 $netmask = $_POST['netmask'];
 $gateway = $_POST['gateway'];
 $mac = $_POST['mac'];
 $dns1 = $_POST['dns1'];
 $dns2 = $_POST['dns2'];
 //echo "ipaddr=$ipaddr;netm ......

PHP+Ajax实现Tab效果

用Ajax实现Tab效果的
先创建
ajax.php,在其中输入如下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample 2_1</title>
<me ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号