2010Äê×îÐÂPHPÀàµÄ¾«Ëõ¹éÄÉ
Ò»£º½á¹¹ºÍµ÷ÓÃ(ʵÀý»¯)£º
class className{} £¬µ÷Óãº$obj = new className();µ±ÀàÓй¹Ô캯Êýʱ£¬»¹Ó¦´«Èë²ÎÊý¡£Èç$obj = new className($v,$v2...);
¶þ£º¹¹Ô캯ÊýºÍÎö¹¹º¯Êý£º
1¡¢¹¹Ô캯ÊýÓÃÓÚ³õʼ»¯£ºÊ¹ÓÃ__construct()£¬¿É´ø²ÎÊý¡£
2¡¢µ«Îö¹¹º¯Êý²»ÄÜ´ø²ÎÊý£¨ÓÃÓÚÔÚÏúÈ¥Ò»¸öÀà֮ǰִÐÐһЩ²Ù×÷»ò¹¦ÄÜ£©¡£Îö¹¹º¯ÊýÓÃ__destruct()×öÃû³Æ¡£Ôڽű¾Ö´ÐнáÊøʱ£¬PHP»áÏúµôÄÚ´æÖеĶÔÏó£¬Òò´Ë¿É²»ÓÃÎöÔ캯Êý£¬µ«ÓÐЩ±ÈÈçCOOKIEµÈ£¬¾ÍÓ¦µ±ÒªÓô˺¯ÊýÏúµô¡£
֪ʶµã£ºÔÚPHP4ÖÐÒ²ÌṩÁ˹¹Ô캯Êý£¬µ«Ê¹ÓõÄÊÇÓëÀàͬÃûµÄÀà·½·¨£¬ÔÚPHP5ÈÔÄܼæÈÝÕâÖÖ×ö·¨£¬µ±Ò»¸öÀàÖÐûÓаüº¬__constructʱ£¬»á²éÕÒÓëÀàͬÃûµÄ·½·¨£¬Èç¹ûÕÒµ½£¬¾ÍÈÏΪÊǹ¹Ô캯Êý£¬ÈçÏ£º
class test
{ var $b;
function test() { $this->b=5; }
function addab($c) { return $this->b+$c; }
}
$a = new test(); echo $a->addab(4); // ·µ»Ø 9
3¡¢PHP²»»á×Ô¶¯µ÷Óø¸ÀàµÄ¹¹Ô캯Êý(²»Ö§³Ö¹¹Ô캯ÊýÖØÔØ)£¬±ØÐëʹÓÃparent¹Ø¼ü×ÖÏÔʽµØµ÷Óá£
class employee{
function __construct()....
}
class Manager extents Employee{
function __construct(){
parent::_construct();
echo 'Õâ¸ö×ÓÀàµÄ¸¸À๹Ô캯Êýµ÷ÓÃÁË£¡';
}
}
µ±È»Ò²¿ÉÒÔµ÷ÓÃÓë¸ÃʵÀýûÓÐÈκιØϵµÄÆäËüÀàµÄ¹¹Ô캯Êý¡£Ö»ÐèÔÚ__construct()Ç°¼ÓÉÏÀàÃû¼´¿É¡£È磺
otherClassName::__construct();
ÀàµÄÖ÷¼ÒÍ¥³ÉÔ±£ºÊôÐÔ¡¢·½·¨¡¢³£Á¿¡¢¾²Ì¬³ÉÔ±
Èý¡¢ÀàµÄÊôÐÔ£º
ÓÐÁ½ÖÖ·½·¨¶ÔÀàµÄÊôÐÔ¸³Öµ»òÈ¡Öµ¡£
1¡¢Ê¹Óù«¹²×÷ÓÃÓòpublic¹Ø¼ü´Ê¡£
2¡¢Ê¹ÓÃ__set()ºÍ__get()À´·Ö±ð¸³ÖµºÍÈ¡Öµ£¬Ç°Õß³ÆΪÉèÖ÷½·¨£¨setter£©»òÐ޸ķ½·¨(mutator)£¬ºóÕß³ÆΪ·ÃÎÊ·½·¨(accessor)»ò»ñÈ¡·½·¨(getter)¡£½¨ÒéʹÓÃÕâÖÖ·½·¨£ºÓŵ㣺
A¡¢¿ÉÔÚ__set£¨£©Í³Ò»½øÐÐÊý¾ÝÑéÖ¤¡£
B¡¢±ãÓÚͳһ¹ÜÀíÊôÐÔ¡£
×¢Ò⣺
µÚÒ»£º__set()ºÍ__get()Ö»¶Ô˽ÓÐÊôÐÔÆð×÷Ó㬶ÔÓÚÓÃpublic¶¨ÒåµÄÊôÐÔ£¬ËüÃÇÁ½¸ö¶¼ÀÁÀí´îÀí£¬ÈçÏ£º
class test{
protected $a=9,$b=2,$c;
public $d;
function __set($n,$v) { $this->$n = $v+2; }
functio
Ïà¹ØÎĵµ£º
ÆäËû³£¼ûµÄÎÞÏÞ·ÖÀà·½·¨£º
1£¬¼òµ¥µÄͨ¹ýµÝ¹é²éѯ¼ÓĿ¼path×ֶεÄÎÞÏÞ·ÖÀà
ȱµã£º²éѯÊý¾Ý¿â´ÎÊýÌ«¶à£¬²»·½±ãÆäËû²Ù×÷£¬±ÈÈçɾ³ý½Úµã¡£Ìí¼Ó½Úµã£¬Òƶ¯½Úµã
2£¬×óÓÒÖµÎÞÏÞ·ÖÀ࣬ԤÅÅÐò¶þ²æÊ÷
ȱµã£º²Ù×÷·±Ëö£¬Êý¾Ý¿âÈßÓ࣬ÇÒÌí¼Óɾ³ýÐ޸Ķ¼Òª½øÐÐ×óÓÒÖµ¸üÐÂ
±¾·ÖÀà·½·¨µÄÓÅÊÆ£º
1£¬Êý¾Ý¿â½á¹¹¼òµ¥£¬Ö»ÓÐ cid parentid ......
PHPÊÇÒ»ÖÖÓÃÓÚ´´½¨¶¯Ì¬WEBÒ³ÃæµÄ·þÎñ¶Ë½Å±¾ÓïÑÔ¡£ÈçͬASPºÍColdFusion£¬Óû§¿ÉÒÔ»ìºÏʹÓÃPHPºÍHTML±àдWEBÒ³Ã棬µ±·ÃÎÊÕßä¯ÀÀµ½¸ÃÒ³Ãæʱ£¬·þÎñ¶Ë»áÊ×ÏȶÔÒ³ÃæÖеÄPHPÃüÁî½øÐд¦Àí£¬È»ºó°Ñ´¦ÀíºóµÄ½á¹ûÁ¬Í¬HTMLÄÚÈÝÒ»Æð´«Ë͵½·ÃÎʶ˵Ää¯ÀÀÆ÷¡£µ«ÊÇÓëASP»ò
ColdFusion²»Í¬£¬PHPÊÇÒ»ÖÖÔ´´úÂ뿪·Å³ÌÐò£¬ÓµÓкܺõĿçƽ̨¼æÈÝÐ ......
¿ÉÒÔʹÓõÄÃüÁ
popen
fpassthru
shell_exec
exec
system
1.popen
resource popen
( string command, string mode )
´ò¿ªÒ»¸öÖ¸Ïò½ø³ÌµÄ¹ÜµÀ£¬¸Ã½ø³ÌÓÉÅÉÉú¸ø¶¨µÄ command
ÃüÁîÖ´Ðжø²úÉú¡£
·µ»ØÒ»¸öºÍ fopen()
Ëù·µ»ØµÄÏàͬµÄÎļþÖ¸Õ룬ֻ²»¹ýËüÊǵ¥ÏòµÄ£¨Ö»ÄÜÓÃÓÚ¶Á»òд£©²¢ÇÒ±ØÐëÓà pclose()
À´¹Ø±Õ ......
<?php
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
//Àý×Ó
//¿ªÊ¼
$time_start = getmicrotime();
//ÕâÀï·ÅÄãµÄ´úÂë
......