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
Ïà¹ØÎĵµ£º
Ò»¡¢×Ö·û´®»ù´¡º¯Êý
ltrim: È¥³ýÁ¬Ðø¿Õ°×¡£
trim: ½ØÈ¥×Ö·û´®Ê×βµÄ¿Õ¸ñ¡£
Chop: º¯Êý´Ó×Ö·û´®µÄÄ©¶Ë¿ªÊ¼É¾³ý¿Õ°××Ö·û»òÆäËûÔ¤¶¨Òå×Ö·û¡££¨rtrim±ðÃû£©
<?php
$str = "Hello World!\n\n";
echo $str;
echo chop($str);
?>
Êä³ö£º
Hello World! Hello World!
htmlspecialchars(string,quotestyle,characte ......
Apache 2 and PHP Installation
The following notes are how I got Apache 2 and PHP 5 (or PHP 4) working together on Linux. These instructions also apply, mostly, for any UNIX-like system, especially other Linux distributions. If you have a recent Linux distribution (say since 2002), you already hav ......
ÎÞÂÛÄÄÖÖÓïÑÔ£¬×Ö·û´®²Ù×÷¶¼ÊÇÒ»¸öÖØÒªµÄ»ù´¡£¬ÍùÍùÊǼòµ¥¶øÖØÒª¡£ÕýÏñÈË˵»°Ò»Ñù£¬Ò»°ãÓÐÐÎÌ壨ͼÐνçÃæ£©£¬ÓÐÓïÑÔ£¨print ×Ö·û´®£¿£©£¬ÏÔÈ»×Ö·û´®ÄܽâÊ͸ü¶àµÄ¶«Î÷¡£PHPÌṩÁË´óÁ¿µÄ×Ö·û´®²Ù×÷º¯Êý£¬¹¦ÄÜÇ¿´ó£¬Ê¹ÓÃÒ²±È½Ï¼òµ¥£¬ÏêϸÇë²Î¿´ http://cn2.php.net/manual/zh/ref.strings.php . ÒÔϽ«¼òµ¥µÄ½²ÊöËüµÄ¹¦ÄܺÍÌØÐ ......
<?php
/* Åжϳ£Á¿ÊÇ·ñ´æÔÚ*/
if (defined('MYCONSTANT')) {
echo MYCONSTANT;
}
//ÅжϱäÁ¿ÊÇ·ñ´æÔÚ
if (isset($myvar)) {
echo "´æÔÚ±äÁ¿$myvar.";
}
//ÅжϺ¯ÊýÊÇ·ñ´æÔÚ
if (function_exists('imap_open')) {
echo "´æÔÚº¯Êýimag_open\n";
} else {
echo "º¯Êýimag_open²»´æÔÚ\n";
}
//ÅжÏÀàÊÇ·ñ ......
±±¾©´óѧPHP¹¤³Ìʦ°àÕÐÉú¼òÕÂ
꿅᣼www.pku-it.com
½üÄêÀ´£¬PHPÓïÑÔÒÔÆä¼ò½àÁé»îµÄ±à³Ìģʽ¡¢ÈÕÇ÷ÍêÉÆµÄ¼¼ÊõÌåϵÒÔ¼°Ç¿ÓÐÁ¦µÄ¿ªÔ´Ö§³Ö£¬Ñ¸ËÙ·¢Õ¹³ÉΪȫÇò»¥ÁªÍøÓ¦ÓÃ×îΪ¹ã·ºµÄ±à³ÌÓïÑÔ¡£Ä¿Ç°ÒÑÓг¬¹ý40%µÄWEB³ÌÐòʹÓÃPHPÀ´±àд£¬°Ù¶È¡¢ÌÚÑ ......