Chinaunix首页 | 论坛 | 博客
  • 博客访问: 17911970
  • 博文数量: 7460
  • 博客积分: 10434
  • 博客等级: 上将
  • 技术积分: 78178
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-02 22:54
文章分类

全部博文(7460)

文章存档

2011年(1)

2009年(669)

2008年(6790)

分类:

2008-05-28 21:12:16


1.简易判断ip地址合法性
2.email的正则判断
3.检测ip地址和mask是否合法的例子
4.关于表单刷新
5.关于表单刷新

php程序员之家


  php程序员站

1.简易判断ip地址合法性if(!strcmp(long2ip(sprintf("%u",ip2long($ip))),$ip)) echo "is ipn";
----
2.email的正则判断eregi("^[_.0-9a-zA-Z-] @([0-9a-zA-Z][0-9a-zA-Z_-] .) [a-zA-Z]___FCKpd___0quot;, $email);
----
3.检测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";?>
----
4.今天解决了一个巨郁闷的问题ipb的添加用户页面toadduser.php似乎会重复提交,导致在添加新用户的时候总是报该用户已经存在...已经郁闷了我3天了,终于搞定,大快人心!
----
5.关于表单刷新问:为什么我在点击浏览器的后退按钮后,所有字段的信息都被清空了?
答:这是由于你在你的表单提交页面中使用了 session_start 函数。该函数会强制当前页面不被缓存。
解决办法为,在你的 Session_start 函数后加入 header("Cache-control: private"); 注意在本行之前你的PHP程序不能有任何输出。
补充:还有基于session的解决方法,在session_start前加上session_cache_limiter('nocache');// 清空表单session_cache_limiter('private'); //不清空表单,只在session生效期间session_cache_limiter('public'); //不清空表单,如同没使用session一般可以在session_start();前加上 session_cache_limiter("private,max-age=10800");摘自phpe.net

phperz.com


----
6.快速搞定文件下载头部输出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'.......2004-08-19 11:50:30
----
7.用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@218.30.116.103/1001/咖哩辣椒/咖喱辣椒.rmvb");.......2004-10-08 13:26:45
----
8.替换所有的字符为*$a=" preg_replace("/./","*", $a);用perl的正则替换,方便
----
9.正则匹配中文ereg("^[".chr(0xa1)."-".chr(0xff)."] ___FCKpd___0quot;, $str); phperz~com
----
10.批量替换文本里面的超级链接'.htmlentities('\1').htmlentities('\2').''EOPHP; $ret = $str; while(list(,$type) = each($types)) {  $ret = preg_replace("|($type://)([^\s]*)|ie ", $replace, $ret); } return $ret;}?> php程序员之家


阅读(472) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~