易截截图软件、单文件、免安装、纯绿色、仅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基本安全防范,初学者必看

1、一般页面通过GET接收的参数都是INT型(整型)居多,但是要防范一些不规范的输入,接收时用整型函数转换一下
            $id=intval($_GET["id"]);
2、有上传功能时,一定要检查文件类型。不能任意由访客上载所有文件。(特别要注意一些HTML编辑器的漏洞)
3 ......

编程小技巧 PHP获文件扩展名的三种方法

方法一:
<?php
function extend_1($file_name)
{
$retval="";
$pt=strrpos($file_name, ".");
if ($pt) $retval=substr($file_name, $pt+1, strlen($file_name) - $pt);
return ($retval);
}
?>
方法二:
function extend_2($file_name)
{
$extend = pathinfo($file_name);
$extend = strto ......

用PHP实现简单的反向最大匹配中文分词(代码)

类文件wordsplit.class.php:
<?php
/********************************************************************
* DirCMS中文分词类 beta 1.0
* ---------------------------
* begin : 2010-5-11 beta 1.0
* update : 2 ......

php cli命令行模式下的使用笔记

php cli命令行模式是WIN下的一个SHELL,不需要APACHE的支持就能执行PHP脚本的脚本,并且是持续执行的。这些特点很容易利用来快速测试PHP脚本。今天就特意找来一些资料,整理了一下,权当复习。
D:\AppServ\php5>php -help
Usage: php [options] [-f] <file> [--] [args...]
     &nbs ......

php/apc 监控文件上传进度

原文地址: 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
//< ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号