易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : php

PHP获取浏览器信息(三种)

转自本人个人网站 【PHP探路者
】,欢迎各位访问站点!
在使用PHP获取浏览器信息时,通常有两种方式:
第一种是:使用$_SERVER[HTTP_USER_AGENT]选项
此方式获取的是格式不规则的数据,如
Mozilla/4.0 (compatible; MSIE 8.0
; Windows NT 5.1; Trident/4.0; GTB6; CIBA; .NET CLR 2.0.50727)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.33
Safari/532.0
具体浏览器型号需要自己分析才能获取,分别是 IE8、Firefox/3.5.5、
Chrome/3.0。
第二种是:使用PHP的get_browser()函数
在使用此函数时,一般会得到如下警告
“Warning
: get_browser() [function.get-browser
]: browscap ini directive
not set. in …”
通过查看PHP手册可以知道,这个函数的使用是有条件的:
Note
: In order for this to
work, your browscap configuration setting in php.ini
must point to
the correct location of the browscap.ini
file on your
system.
browscap.ini
is ......

PHP序列化用到的构造:__sleep() __wakeup()

在PHP进行序列化时,serialize() 检查类中是否有 __sleep() ,如果有,则该函数将在任何序列化之前运行。该函数必须返回一个需要进行序列化保存的成员属性数组,并且只序列化该函数返回的这些成员属性. 该函数有两个作用: 第一. 在序列化之前,关闭对象可能具有的任何数据库连接等. 第二. 指定对象中需要被序列化的成员属性,如果某个属性比较大而不需要储存下来,可以不把它写进__sleep要返回的数组中,这样该属性就不会被序列化
相反地,unserialize() 从字节流中创建了一个对象之后,马上检查是否具有__wakeup 的函数的存在。如果存在,__wakeup 立刻被调用。使用 __wakeup 的目的是重建在序列化中可能丢失的任何数据库连接以及处理其它重新初始化的任务。
<?php
   class User
   {
       public $name;
       public $id;
       function __construct()
       {
           $this->id = uniqid();         ......

SQLite Tutorial in PHP

 
SQLite Tutorial in PHP
SQLite is an SQL database manager used locally or on a website, and compatible
in particularly with PHP.
Summary
Installing SQLite and creating a database
.
Installing SQLite. Verifying the installation by creating a base.
Creating and using a SQLite table
.
Creating a table. Deleting a table. Adding a record. Reading a record.
How to find and update a post
.
Filling a database. Dump of the whole base. Finding a record by ID. Searching a post. Updating a post.
Download
The complete source code of the scripts
in a ZIP archive.
More
SQLite and multi-users. How to treat concurrency issue with SQLite
. ......

SQLite Tutorial in PHP

 
SQLite Tutorial in PHP
SQLite is an SQL database manager used locally or on a website, and compatible
in particularly with PHP.
Summary
Installing SQLite and creating a database
.
Installing SQLite. Verifying the installation by creating a base.
Creating and using a SQLite table
.
Creating a table. Deleting a table. Adding a record. Reading a record.
How to find and update a post
.
Filling a database. Dump of the whole base. Finding a record by ID. Searching a post. Updating a post.
Download
The complete source code of the scripts
in a ZIP archive.
More
SQLite and multi-users. How to treat concurrency issue with SQLite
. ......

php和java上传文件的方法

java上传文件
需要的第三方jar包有(这里使用apache的)
apache的commons-fileupload(上传用),commons-io (listener清理类用) , commons-beanutils(可选)
具体操作
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
if(ServletFileUpload.isMultipartContent(request)) { //判断请求类型是不是multipart
try {
List<FileItem> fileList = upload.parseRequest(request);
for(FileItem item : fileList) {
if(!item.isFormField()) { //判断是不是文件表单
String filename = item.getName();
String ext = filename.substring(filename.indexOf(".") + 1);
if(!"dic".equalsIgnoreCase(ext)) {
out.println("file type must be .dic");
} else {
File uploadedFile = new File(path + "/" + filename);
item.write(uploadedFile); //保存
out.println("upload ok");
}
}
}
} catch (FileUploadException e) {
e.printStackTrace();
} catch (Exc ......

php和java上传文件的方法

java上传文件
需要的第三方jar包有(这里使用apache的)
apache的commons-fileupload(上传用),commons-io (listener清理类用) , commons-beanutils(可选)
具体操作
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
if(ServletFileUpload.isMultipartContent(request)) { //判断请求类型是不是multipart
try {
List<FileItem> fileList = upload.parseRequest(request);
for(FileItem item : fileList) {
if(!item.isFormField()) { //判断是不是文件表单
String filename = item.getName();
String ext = filename.substring(filename.indexOf(".") + 1);
if(!"dic".equalsIgnoreCase(ext)) {
out.println("file type must be .dic");
} else {
File uploadedFile = new File(path + "/" + filename);
item.write(uploadedFile); //保存
out.println("upload ok");
}
}
}
} catch (FileUploadException e) {
e.printStackTrace();
} catch (Exc ......

从php编码习惯谈程序效率!


尽量使用单引号而不是双引号。
尽量使用带条件的include而不是require。
尽量使用echo而不是print。
尽量使用内嵌的HTML而不是echo。
尽量使用str-replace()而不是ereg-replace()。
尽量sql不用联合查询。
......

PHP函数strtotime详解

 strtotime函数是一个很好的函数,灵活的运用它,会给你的工作带来不少方便.但PHP的手册中却对此函数的参数没作太多介绍,对些函数的其他介绍也非常少。
先看手册介绍:
strtotime — 将任何英文文本的日期时间描述解析为 Unix 时间戳
格式:int strtotime ( string $time [, int $now ] )
  本函数预期接受一个包含美国英语日期格式的字符串并尝试将其解析为 Unix 时间戳(自 January 1 1970 00:00:00 GMT 起的秒数),其值相对于 now 参数给出的时间,如果没有提供此参数则用系统当前时间。
  本函数将使用 TZ 环境变量(如果有的话)来计算时间戳。自 PHP 5.1.0 起有更容易的方法来定义时区用于所有的日期/时间函数。此过程在 date_default_timezone_get() 函数页面中有说明。
Note : 如果给定的年份是两位数字的格式,则其值 0-69 表示 2000-2069,70-100 表示 1970-2000。
参数
time
被解析的字符串,格式根据 GNU » 日期输入格式 的语法。在 PHP 5.0 之前,time 中不允许有毫秒数,自 PHP 5.0 起可以有但是会被忽略掉。
now
用来计算返回值的时间戳。 该参数默认值是当前时间time(),也可以设置为其他时间的时间戳(我一直忽略的一个功� ......
总记录数:2174; 总页数:363; 每页6 条; 首页 上一页 [255] [256] [257] [258] 259 [260] [261] [262] [263] [264]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号