- 浏览: 272724 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (234)
- php (70)
- linux (46)
- apache (9)
- mysql (13)
- oauth (1)
- IT新闻 (18)
- 代码收藏 (20)
- python (2)
- webservice (6)
- 评论 (7)
- asd (0)
- 开源软件 (6)
- 前端 (9)
- 7z (1)
- js (17)
- windows (4)
- cmd (2)
- 开源 (3)
- vim (6)
- windows 软件安装错误 (2)
- 分享 (3)
- search (1)
- node.js (1)
- xmind (1)
- 变成语言 (1)
- drupal (0)
- jquery (2)
- css (7)
- ietester (1)
- 编辑器 (1)
- java (2)
- html5 (1)
- 生活 (1)
- Sublime Text 2 (1)
- 制图 (0)
- sublime (1)
最新评论
-
muxueqz:
我自己写了个开源的:http://muxueqz.top/sk ...
Delicious被Yahoo卖了 -
yangyongnihao:
...
REST与SOAP样式Web 服务的区别 -
wangshaofei:
zhou7707 写道 大神啊,太及时了,我今天服务器上不了 ...
Debian 6 下搭建nginx 1.3 -
zhou7707:
大神啊,太及时了,我今天服务器上不了外网,为搞包依赖折腾一 ...
Debian 6 下搭建nginx 1.3 -
wangshaofei:
bbs_ld 写道一楼说的对啊。如何解决呢?? 高手大人
利用php创建日期选择框
本文汇集PHP开发中经常用到的时段代码,包括Email、解压缩、64位编码、解析JSON等,希望对您有所帮助。 1、使用PHP Mail函数发送Email $to = "viralpatel.net@gmail.com"; $subject = "VIRALPATEL.net"; $body = "Body of your message here you can use HTML too. e.g. ﹤br﹥ ﹤b﹥ Bold ﹤/b﹥"; $headers = "From: Peter\r\n"; $headers .= "Reply-To: info@yoursite.com\r\n"; $headers .= "Return-Path: info@yoursite.com\r\n"; $headers .= "X-Mailer: PHP5\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to,$subject,$body,$headers); ?﹥ 2、PHP中的64位编码和解码 function base64url_encode($plainText) { $base64 = base64_encode($plainText); $base64url = strtr($base64, '+/=', '-_,'); return $base64url; } function base64url_decode($plainText) { $base64url = strtr($plainText, '-_,', '+/='); $base64 = base64_decode($base64url); return $base64; } 3、获取远程IP地址 function getRealIPAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } 4、 日期格式化 function checkDateFormat($date) { //match the format of the date if (preg_match ("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/", $date, $parts)) { //check weather the date is valid of not if(checkdate($parts[2],$parts[3],$parts[1])) return true; else return false; } else return false; } 5、验证Email $email = $_POST['email']; if(preg_match("~([a-zA-Z0-9!#$%&'*+-/=?^_`{|}~])@([a-zA-Z0-9-]). ([a-zA-Z0-9]{2,4})~",$email)) { echo 'This is a valid email.'; } else{ echo 'This is an invalid email.'; } 6、在PHP中轻松解析XML //this is a sample xml string $xml_string="﹤?xml version='1.0'?﹥ ﹤moleculedb﹥ ﹤molecule name='Benzine'﹥ ﹤symbol﹥ben﹤/symbol﹥ ﹤code﹥A﹤/code﹥ ﹤/molecule﹥ ﹤molecule name='Water'﹥ ﹤symbol﹥h2o﹤/symbol﹥ ﹤code﹥K﹤/code﹥ ﹤/molecule﹥ ﹤/moleculedb﹥"; //load the xml string using simplexml function $xml = simplexml_load_string($xml_string); //loop through the each node of molecule foreach ($xml-﹥molecule as $record) { //attribute are accessted by echo $record['name'], ' '; //node are accessted by -﹥ operator echo $record-﹥symbol, ' '; echo $record-﹥code, '﹤br /﹥'; } 7、数据库连接 ﹤?php if(basename(__FILE__) == basename($_SERVER['PHP_SELF'])) send_404(); $dbHost = "localhost"; //Location Of Database usually its localhost $dbUser = "xxxx"; //Database User Name $dbPass = "xxxx"; //Database Password $dbDatabase = "xxxx"; //Database Name $db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database."); mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database."); # This function will send an imitation 404 page if the user # types in this files filename into the address bar. # only files connecting with in the same directory as this # file will be able to use it as well. function send_404() { header('HTTP/1.x 404 Not Found'); print '﹤!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"﹥'."n". '﹤html﹥﹤head﹥'."n". '﹤title﹥404 Not Found﹤/title﹥'."n". '﹤/head﹥﹤body﹥'."n". '﹤h1﹥Not Found﹤/h1﹥'."n". '﹤p﹥The requested URL '. str_replace(strstr($_SERVER['REQUEST_URI'], '?'), '', $_SERVER['REQUEST_URI']). ' was not found on this server.﹤/p﹥'."n". '﹤/body﹥﹤/html﹥'."n"; exit; } # In any file you want to connect to the database, # and in this case we will name this file db.php # just add this line of php code (without the pound sign): # include"db.php"; ?﹥ 8、创建和解析JSON数据 $json_data = array ('id'=﹥1,'name'=﹥"rolf",'country'=﹥'russia', "office"=﹥array("google","oracle")); echo json_encode($json_data); 9、处理MySQL时间戳 $query = "select UNIX_TIMESTAMP(date_field) as mydate from mytable where 1=1"; $records = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($records)) { echo $row; } 10、解压缩Zip文件 ﹤?php function unzip($location,$newLocation){ if(exec("unzip $location",$arr)){ mkdir($newLocation); for($i = 1;$i﹤ count($arr);$i++){ $file = trim(preg_replace("~inflating: ~","",$arr[$i])); copy($location.'/'.$file,$newLocation.'/'.$file); unlink($location.'/'.$file); } return TRUE; }else{ return FALSE; } } ?﹥ //Use the code as following: ﹤?php include 'functions.php'; if(unzip('zipedfiles/test.zip','unziped/myNewZip')) echo 'Success!'; else echo 'Error'; ?﹥
发表评论
-
11111
2013-07-04 00:45 0qqqqqqqqqqqqq -
xcc
2013-06-24 17:41 0xxx -
征婚网站
2013-06-09 17:44 0征婚网站 -
CodeIgniter 用户指南 版本 2.1.3
2013-05-23 02:25 743CodeIgniter 是一套给 PHP 网站开发者使用的应用 ... -
xampp windows xdebug netbeans
2013-04-17 00:15 713xdebug config in php.ini xdeb ... -
Installing_Nginx_With_PHP5_And_MySQL_Support_On_Debian_Squeeze.rar
2013-03-17 20:37 612Installing_Nginx_With_PHP5_And_ ... -
Debian 6 下搭建nginx 1.3
2013-03-17 18:27 16391 准备debian 6.0环境 2 下载需要安装的 ... -
这样用google
2013-01-10 12:49 992美国人教你这样用Google,你真的会变特工!!!来源: ... -
NetBeans Hot Keys
2012-12-16 17:01 647最近使用netbeans,发现还不错NetBeans Hot ... -
drupal开发
2012-10-12 09:35 0在请求的url中获取回调函数,根据回调函数来判断页面显 ... -
php windows xp zip
2012-09-28 10:31 592php windows xp zip -
drupal7源码和文档
2012-09-19 08:00 596drupal7源码和文档 -
我的文件
2012-06-29 17:18 0阿道夫 -
Nginx + PHP5
2012-06-03 02:44 760WINDOWS下应该有PHP-FPM类 ... -
SSH的官方下载地址
2012-05-15 11:05 0这里分别是SSH的官方下载地址: Struts2.0: ... -
php文档
2012-05-11 10:34 674php文档。 -
php set_magic_quotes_runtime() 函数过时解决方法
2011-11-15 09:45 889tags标签: set_magic_quotes_runtim ... -
php静态方法调用非静态方法不可取
2011-11-08 15:22 2326那天对这个主题比较感 ... -
国外PHP老手谈为何放弃PHP而改用Python
2011-11-01 13:28 989本文作者做了11年的P ... -
vim 相关操作方法命令
2011-10-28 13:22 26231. 翻页 整页翻页 ctrl-f ctrl-b f就是f ...
相关推荐
一些常用功能的PHP代码
资源名称:PHP常用功能块内容简介:1. 错误和异常处理2. 日期和时间3. 动态图像处理一、错误和异常处理™ 1.1 错误类型和基本的调试方法™ 1.2 错误日志™ 1.3 异常处理1.1 错误类型和基本的调试方法™ PHP程序的...
本文汇集PHP开发中经常用到的时段代码,包括Email、解压缩、64位编码、解析JSON等,对php常用代码感兴趣的朋友参考下
常用php系统添加文件 PHPCMS V9 \phpcms\base.php PHPWIND8.7 \data\sql_config.php DEDECMS5.7 \data\common.inc.php DiscuzX2 \config\config_global.php Wordpress \wp-config.php Metinfo \include\head.php b)....
1.常用功能 会员登记,会员充值,会员充次,商品消费(会员),商品消费(散客),快速消费(会员),快速消费(散客),计次消费,挂单列表 打印区 消费打印,充值打印,交班打印 报表中心 消费流水,消费明细表 2....
主要介绍了PHP常用的小程序代码段,包括计算时间差、分页及查询手机归属地等功能代码,具有一定参考借鉴价值,需要的朋友可以参考下
第10章介绍PHP中常用的加密算法;第11章从设计安全功能的角度出发,从攻击者的角度详细分析常见功能通常会出现的安全问题以及解决方案;第12章介绍企业的应用安全体系建设,介绍横向细化策略和纵深防御策略的具体...
平时做项目后台时一些经常用到的前端功能总结。适用于layui。包括弹框,删除按钮,添加按钮,表单,select下拉框
第10章介绍PHP中常用的加密算法;第11章从设计安全功能的角度出发,从攻击者的角度详细分析常见功能通常会出现的安全问题以及解决方案;第12章介绍企业的应用安全体系建设,介绍横向细化策略和纵深防御策略的具体...
php一些常用函数,一些基本功能的实现
phpcn内置了输入法提示功能,使你快速地输入你想要的函数,同时配置了输入法统计功能,可以提高编程效率,快速匹配用户常用的函数。 phpcn绿色,没有任何广告。小巧,压缩包只有4M大小。 phpcn内置了976个php函数...
PHP100视频教程10:MYSQL在PHP5中的应用 PHP100视频教程11:学习制作PHP+MYSQL留言板(上) PHP100视频教程12:学习制作PHP+MYSQL留言板(下) PHP100视频教程13:PHP+MYSQL分页原理 PHP100视频教程14:PHP上传...
一个非常容易使用,但功能强大并且快速的模板引擎,它帮助你把页面布局和设计从代码中分离。 FastTemplate 一个简单的变量插值模板类,它分析你的模板,把变量的值从HTML代码中分离处理。 ShellPage 一个简单易用的...
快写代码编辑器是一款中文代码编辑器,支持中文编写PHP、HTML、CSS,支持多种编程语言的语法高亮、拥有优秀的代码自动完成功能。 快写代码编辑器主要功能: 1、简洁的界面 2、用中文编写代码 3、中英代码互转 ...
下面的 PHP 代码就实现了发送 SMS 的功能。 为了使用任何的语言发送 SMS,需要一个 SMS gateway。大部分的 SMS 会提供一个 API,这里是使用 MSG91 作为 SMS gateway。 function send_sms($mob
PHP自动发送到邮箱/手机反馈系统可以将访客的反馈信息自动发送到您常用的邮箱里,甚至还可以通过QQ邮箱的手机邮箱功能免费发送到您的手机上,让您第一时间收到访客的反馈信息。
动态网站设计概述、动态网站编程环境、网站主页设计与PHP基础、网站计数器设计与PHP文件访问、会员注册和管理设计与数据获取、网上社区设计与PHP数据库访问、网上购书与PHP面向对象技术、网站优化与PHP的高级功能等...
提供方便快捷的日期选择功能,可实现点击日历上的日期达到日期选择功能,试用方便,可以在JSP ASP PHP等各种网站中嵌套
php实现登录及注册功能,源码文件,该代码实现了一套常用的用户登录,用户信息注册,修改以及一览的功能
ASP.NET常用代码 1. 打开新的窗口并传送参数: 传送参数: response.write("<script>window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"')</script>") 接收参数: string a = Request....