PHPÀàʵÀý½Ì³Ì£¨Ê®£©£ºÀàµÄÖØд£¨override£©
Èç¹û´Ó¸¸Àà¼Ì³ÐµÄ·½·¨²»ÄÜÂú×ã×ÓÀàµÄÐèÇ󣬿ÉÒÔ¶ÔÆä½øÐиÄд£¬Õâ¸ö¹ý³Ì½Ð·½·¨µÄ¸²¸Ç£¨override£©£¬Ò²³ÆΪ·½·¨µÄÖØд¡£
µ±¶Ô¸¸ÀàµÄ·½·¨½øÐÐÖØдʱ£¬×ÓÀàÖеķ½·¨±ØÐëºÍ¸¸ÀàÖжÔÓ¦µÄ·½·¨¾ßÓÐÏàͬµÄ·½·¨Ãû³Æ£¬ÔÚPHP5Öв»ÏÞÖÆÊäÈë²ÎÊýÀàÐÍ¡¢²ÎÊýÊýÁ¿ºÍ·µ»ØÖµÀàÐÍ¡££¨ÕâµãºÍJAVA²»Í¬£©
×ÓÀàÖеĸ²¸Ç·½·¨²»ÄÜʹÓñȸ¸ÀàÖб»¸²¸Ç·½·¨¸üÑϸñµÄ·ÃÎÊȨÏÞ¡£
ÉùÃ÷·½·¨Ê±£¬Èç¹û²»¶¨Òå·ÃÎÊȨÏÞ¡£Ä¬ÈÏȨÏÞΪpublic¡£
ÏÈÉèÖÃÒ»¸ö¸¸À࣬Õâ¸ö¸¸ÀàÊÇ “Dog”À࣬Õâ¸öÀàÃèÊöÁËdogµÄÌØÐÔ¡£DogÓÐ2¸öÑÛ¾¦£¬»áÅÜ£¬»á½Ð¡£¾ÍÕâÑùÃèÊöÏÈ¡£ÎÒÑøÁËÒ»Ö±¹·£¬ÊÇֻС¹·£¬·ûºÏDogÀàµÄÌØÐÔ£¬µ«ÓÐËù²»Í¬¡£ÎÒµÄС¹·ÓÐÃû×Ö£¬ÎÒµÄС¹·Ì«Ð¡ÁË£¬²»»á´óÉùµÄ½Ð£¬Ö»»áºßºß¡£ ÎÒÃÇÓü̳еĸÅÄîȥʵÏÖÕâ¸öÉè¼Æ¡£
<?php
//¹·ÓÐÁ½Ö»ÑÛ¾¦£¬»áÍôÍô½Ð£¬»áÅÜ
class Dog
{
protected $eyeNumber = 2; //
//·µ»Ø·â×°µÄÊôÐÔ·½·¨
public function getEyeNumber() {
return $this->eyeNumber;
}
//¹·»á½Ð
public function yaff() {
return "Dog yaff, wang ..wang ..";
}
//¹·»áÅÜ
public function run() {
return "Dog run..running ...";
}
}
$dog = new Dog();
echo "dog have " . $dog->getEyeNumber() . " eyes. <br />";
echo $dog->yaff() . "<br />" . $dog->run();
echo "<br /><br /><br /><br />";
//ÕâÊÇÎÒµÄС¹·£¬½Ð"¹·¹·",Ëû»¹Ð¡²»»áÍôÍô½Ð£¬Öǻۺߺߡ£¡£
class MyDog extends Dog
{
private $name = "";
public function getName() {
return $this->name;
}
public function yaff() {
return $this->name . " yaff, heng...heng ..";
}
}
$myDog = new MyDog();
echo $myDog->getName() . " have " . $myDog->getEyeNumber() . " eyes. <br />";
echo $myDog->yaff() . "<br />" . $myDog->run();
?>
ÖØд·½·¨Óë·ÃÎÊȨÏÞ
×ÓÀàÖеĸ²¸Ç·½·¨²»ÄÜʹÓñȸ¸ÀàÖб»¸²¸Ç·½·¨¸üÑϸñµÄ·ÃÎÊȨÏÞ¡£
Ïà¹ØÎĵµ£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
php´úÂë:
<?php
class ChineseSpell {
/**
* @var array $chineseSpellList Æ´Òô±àÂë¶ÔÓ¦±í
* @access private
*/
private $chineseSpellList = array(
'a'=>-20319,
'ai'=>-20317,
&nbs ......
Õâ¸öϵͳÆäʵÊÇÁ·Ï°php»ù±¾Óï·¨ºÍMySQLµÄ»ù±¾²éѯÓï¾ä¡£¸øÒ»ÆðѧϰµÄÅóÓÑ·ÖÏí¡£ ^_^
ÔÚphpÎļþÖУ¬Ë«Ð±¸ÜºóÃæÊÇ×¢ÊÍÓï¾ä£¬ÎÒÓÃÓ¢ÎÄдµÄ×¢ÊÍ¡£
Õû¸öϵͳËù°üº¬µÄ.htmºÍ.phpÎļþÓУº
add_que.htm——Ìí¼ÓÐÂÌâµÄÒ³Ãæ
insert.php——ÏÔʾÌí¼ÓÐÂÌâÐÅÏ¢µÄÒ³Ãæ
questionlist.php——ËùÓÐÎÊÌâÁÐ ......
¹¹Ôì·½·¨ÓÖ³ÆΪ¹¹Ô캯Êý£¬ÊǶÔÏó±»´´½¨Ê±×Ô¶¯µ÷Óõķ½·¨£¬ÓÃÀ´Íê³ÉÀà³õʼ»¯µÄ¹¤×÷¡£
¹¹Ô캯ÊýºÍÆäËüº¯ÊýÒ»Ñù£¬¿ÉÒÔ´«µÝ²ÎÊý£¬¿ÉÒÔÉ趨²ÎÊýĬÈÏÖµ¡£¹¹Ô캯Êý¿ÉÒÔµ÷ÓÃÊôÐÔ£¬¿ÉÒÔµ÷Ó÷½·¨¡£¹¹Ô캯Êý¿ÉÒÔ±»ÆäËü·½·¨ÏÔʽµ÷Óá£
ÔÚPHP4 ÖÐʹÓÃÓëÀàÃûͬÃûµÄ·½·¨Îª¹¹Ô캯Êý¡£ÔÚPHP5ÖÐÒÀȻ֧³ÖÁËÕâÖÖ·½Ê½£¬µ«²»½¨ÒéÔÙʹÓÃÕâÖÖ·½Ê½¡ ......
Ò³ÃæµÄÖض¨Ïò£¬ËãÊǺܳ£ÓõŦÄÜÁË¡£ÏÂÃæժ¼³£ÓõÄ3ÖÖ·½·¨£º
<?php
¡¡¡¡if (isset($url))
¡¡¡¡{
¡¡¡¡Header("HTTP/1.1 303 See Other");
¡¡¡¡Header("Location: $url");
¡¡¡¡exit; //from www.kjsc.com.cn
¡¡¡¡}
¡¡¡¡?>
¡¡¡¡×¢Òâһϣ¬"Localtion:"ºóÃæÓÐÒ»¸ö¿Õ¸ñ¡£
¡¡¡¡¶ ......