PHPµÄ·¢Õ¹
PHP Ô±¾µÄ¼ò³ÆÎª Personal Home Page£¬ÊÇRasmus Lerdorf ΪÁËҪά»¤¸öÈËÍøÒ³£¬¶øÓÃcÓïÑÔ¿ª·¢µÄһЩCGI¹¤¾ß³ÌÐò¼¯£¬À´È¡´úÔÏÈʹÓÃµÄ Perl ³ÌÐò¡£×î³õÕâЩ¹¤¾ß³ÌÐòÓÃÀ´ÏÔʾ Rasmus Lerdorf µÄ¸öÈËÂÄÀú£¬ÒÔ¼°Í³¼ÆÍøÒ³Á÷Á¿¡£Ëû½«ÕâЩ³ÌÐòºÍһЩ±íµ¥Ö±ÒëÆ÷ÕûºÏÆðÀ´£¬³ÆÎª PHP/FI¡£PHP/FI ¿ÉÒÔºÍÊý¾Ý¿âÁ¬½Ó£¬²úÉú¼òµ¥µÄ¶¯Ì¬ÍøÒ³³ÌÐò¡£Rasmus Lerdorf ÔÚ1995Äê6ÔÂ8ÈÕ½« PHP/FI ¹«¿ªÊͳö£¬Ï£Íû¿ÉÒÔ͸¹ýÉçȺÀ´¼ÓËÙ³ÌÐò¿ª·¢ÓëѰÕÒ´íÎó¡£Õâ¸öÊͳöµÄ°æ±¾ÃüÃûΪ PHP 2£¬ÒѾÓнñÈÕ PHP µÄһЩ³ûÐÍ£¬ÏñÊÇÀàËÆ Perl µÄ±äÁ¿ÃüÃû·½Ê½¡¢±íµ¥´¦Àí¹¦ÄÜ¡¢ÒÔ¼°Ç¶Èëµ½ HTML ÖÐÖ´ÐеÄÄÜÁ¦¡£³ÌÐòÓï·¨ÉÏÒ²ÀàËÆ Perl£¬Óн϶àµÄÏÞÖÆ£¬²»¹ý¸ü¼òµ¥¡¢¸üÓе¯ÐÔ¡£
¡¡¡¡ÔÚ1997Ä꣬ÈÎÖ°ÓÚ Technion IIT ¹«Ë¾µÄÁ½¸öÒÔÉ«ÁгÌÐòÉè¼ÆÊ¦£ºZeev Suraski ºÍ Andi Gutmans£¬ÖØÐ´ÁË PHP µÄÆÊÎöÆ÷£¬³ÉΪ PHP 3 µÄ»ù´¡£¬¶ø PHP Ò²ÔÚÕâ¸öʱºò¸Ä³ÆÎªPHP: Hypertext Preprocessor.[5]¡£¾¹ý¼¸¸öÔ²âÊÔ£¬¿ª·¢ÍŶÓÔÚ1997Äê11ÔÂÊͳöÁË PHP/FI 2£¬Ëæºó¾Í¿ªÊ¼ PHP 3 µÄ¿ª·Å²âÊÔ£¬×îºóÔÚ1998Äê6ÔÂÕýʽÊͳö PHP 3¡£Zeev Suraski ºÍ Andi Gutmans ÔÚ PHP 3 Êͳöºó¿ªÊ¼¸Äд PHP µÄºËÐ ......
cookieĬÈϲ»ÄÜ´æÊý×飬ËùÒÔÏÂÃæµÄд·¨ÊÇ´íÎóµÄ¡£
<?php
$arr = array(1,2,3);
setcookie('a',$arr);
$arr = array(1,2,3);
setcookie('a',$arr);
?>
±¨´íÈçÏ£º
Warning: setcookie() expects parameter 2 to be string, array given in
µ«ÊÇPHP¿ÉÒÔ°ÑͬÃûÇÒºóÃæÒÔ[]½áβµÄcookie½âÎöΪÊý×é¡£ÔÚphpÀïÃæÊµÏÖcookie´æÊý×éµÄ·½·¨ÈçÏ£º
·½·¨Ò»£ºÏÈÓÃserializeÐòÁл¯Êý×飬ÔÙ´æÈëCOOKIE ,¶Á³öÀ´Ê±ÓÃunserializeµÃµ½ÔÀ´µÄÊý×é
//´æÈë
$arr = array(1,2,3);
$arr_str = serialize($arr);
setcookie("a",$arr_str);
//È¡³ö
$arr_str = $_COOKIE['a'];
$arr = unserialize($arr_str);
//´æÈë
$arr = array(1,2,3);
$arr_str = serialize($arr);
setcookie("a",$arr_str);
//È¡³ö
$arr_str = $_COOKIE['a'];
$arr = unserialize($arr_str);
·½·¨¶þ£ºÉ趨¶à¼üÖµcookie£¬×¢Òâ±ØÐë¸ø¼üÖµ
$arr = array(1,2,3); ......
ת×Ô±¾È˸öÈËÍøÕ¾ ¡¾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½øÐÐÐòÁл¯Ê±£¬serialize() ¼ì²éÀàÖÐÊÇ·ñÓÐ __sleep() ,Èç¹ûÓУ¬Ôò¸Ãº¯Êý½«ÔÚÈκÎÐòÁл¯Ö®Ç°ÔËÐС£¸Ãº¯Êý±ØÐë·µ»ØÒ»¸öÐèÒª½øÐÐÐòÁл¯±£´æµÄ³ÉÔ±ÊôÐÔÊý×飬²¢ÇÒÖ»ÐòÁл¯¸Ãº¯Êý·µ»ØµÄÕâЩ³ÉÔ±ÊôÐÔ. ¸Ãº¯ÊýÓÐÁ½¸ö×÷ÓÃ: µÚÒ». ÔÚÐòÁл¯Ö®Ç°,¹Ø±Õ¶ÔÏó¿ÉÄܾßÓеÄÈκÎÊý¾Ý¿âÁ¬½ÓµÈ. µÚ¶þ. Ö¸¶¨¶ÔÏóÖÐÐèÒª±»ÐòÁл¯µÄ³ÉÔ±ÊôÐÔ,Èç¹ûij¸öÊôÐÔ±È½Ï´ó¶ø²»ÐèÒª´¢´æÏÂÀ´,¿ÉÒÔ²»°ÑËüд½ø__sleepÒª·µ»ØµÄÊý×éÖÐ,ÕâÑù¸ÃÊôÐԾͲ»»á±»ÐòÁл¯
Ïà·´µØ£¬unserialize() ´Ó×Ö½ÚÁ÷Öд´½¨ÁËÒ»¸ö¶ÔÏóÖ®ºó,ÂíÉϼì²éÊÇ·ñ¾ßÓÐ__wakeup µÄº¯ÊýµÄ´æÔÚ¡£Èç¹û´æÔÚ£¬__wakeup Á¢¿Ì±»µ÷Óá£Ê¹Óà __wakeup µÄÄ¿µÄÊÇÖØ½¨ÔÚÐòÁл¯ÖпÉÄܶªÊ§µÄÈκÎÊý¾Ý¿âÁ¬½ÓÒÔ¼°´¦ÀíÆäËüÖØÐ³õʼ»¯µÄÈÎÎñ¡£
<?php
class User
{
public $name;
public $id;
function __construct()
{
$this->id = uniqid();   ......
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 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
. ......
javaÉÏ´«Îļþ
ÐèÒªµÄµÚÈý·½jar°üÓУ¨ÕâÀïʹÓÃapacheµÄ£©
apacheµÄcommons-fileupload£¨ÉÏ´«Óã©£¬commons-io £¨listenerÇåÀíÀàÓã© £¬ commons-beanutils£¨¿ÉÑ¡£©
¾ßÌå²Ù×÷
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
if(ServletFileUpload.isMultipartContent(request)) { //ÅжÏÇëÇóÀàÐÍÊDz»ÊÇmultipart
try {
List<FileItem> fileList = upload.parseRequest(request);
for(FileItem item : fileList) {
if(!item.isFormField()) { //ÅжÏÊDz»ÊÇÎļþ±íµ¥
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 ......
javaÉÏ´«Îļþ
ÐèÒªµÄµÚÈý·½jar°üÓУ¨ÕâÀïʹÓÃapacheµÄ£©
apacheµÄcommons-fileupload£¨ÉÏ´«Óã©£¬commons-io £¨listenerÇåÀíÀàÓã© £¬ commons-beanutils£¨¿ÉÑ¡£©
¾ßÌå²Ù×÷
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
if(ServletFileUpload.isMultipartContent(request)) { //ÅжÏÇëÇóÀàÐÍÊDz»ÊÇmultipart
try {
List<FileItem> fileList = upload.parseRequest(request);
for(FileItem item : fileList) {
if(!item.isFormField()) { //ÅжÏÊDz»ÊÇÎļþ±íµ¥
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 ......