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

php常用技巧

如何判断ip地址合法性
if(!strcmp(long2ip(sprintf("%u",ip2long($ip))),$ip)) echo "is ipn";
 email的正则判断
eregi("^[_.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z_-]+.)+[a-zA-Z]$", $email);
检测ip地址和mask是否合法的例子
$ip = '192.168.0.84';
$mask = '255.255.255.0';
$network = '192.168.0';
$ip = ip2long($ip);
$mask = ip2long($mask);
$network = ip2long($network);
if( ($ip & $mask) == $network) echo "valid ip and maskn";
?>
文件下载头部输出如何设定
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename=$file_download_name;");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
echo 'xxx'
用header输出ftp下载方式,并且支持断点续传
一个例子:
header('Pragma: public');
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Accept-Ranges: bytes');
header('Connection: close');
header("Content-Type: audio/mpeg");
header("Location:ftp://download:1bk3l4s3k9s2@232.2.22.22/2222/web技术开发知识库/cn_web.rmvb");
正则匹配中文
ereg("^[".chr(0xa1)."-".chr(0xff)."]+$", $str);
批量替换文本里面的超级链接
<?php
function urlParse($str = ''){
    if ('' == $str) return $str;
$types = array("http", "ftp", "https");
$replace = <<<EOPHP
  '<a href="'.htmlentities('\1').htmlentities('\2').'">'.htmlentities('\1').htmlentities('\2').'</a>'
EOPHP;
$ret = $str;
while(list(,$type) = each($types)){
  $ret = preg_replace("|($type://)([^\s]*)|ie ", $replace, $ret);
}
return $ret;
}
?>


相关文档:

PHP UUID的生成源码

现在好多地方都用UUID,比如数据库的个自动的UUID
UUID结构如下(都为十六进制字符)
XXXXX
XXX-XXXX-XXXX-XXXX-XXXXXXXXXXX
研究其生成实现过程才发现,原来是这样的
1、提取当前时候值和时间戳
2、把这两个值转换成十六进制
3、取时间值和时间戳的前5和时间值的前六位
4、生成一个三位的十六进制,三个四位的 ......

php中substr的用法详解

php中substr的用法详解
php.net中关于substr的说明很简单:
start
If start is non-negative, the returned string will start at the start 'th position in string , counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so for ......

PHP多语言系统的一种实现方式[转]


在网站设计中我们经常会遇到需要多语言支持的情况。多语言系统按照支持的方式一般可分为两种:
1.支持多语言,但不支持多种语言的同时存在,也就是说要么是中文要么是英文或者其他,这在一些需要国际化支持的网页系统中经常用来,以便方便用户本地化。 2.支持多语言并可同时浏览不同语言版本的网页。今天我想讨 ......

PHP 中 in_array 函数的用法与注意项

in_array(value,array,type)
in_array 作用是用于查看 value 是否在 array 中存在,如果参数 value 是字符串,且 type 参数设置为 true,则搜索区分大小写。则 in_array 是 区分大小写 的。
有一点需要注意,当 array 中包含 value 的值,则返回 true; 但是,如果两者参数之间相等,则返回 false
例如:
$str = 'a';
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号