PHPÀàʵÀý½Ì³Ì£¨¶þÊ®Èý£©£ºPHP³éÏóÀàʵÏÖ½Ó¿Ú
<p>³éÏóÀàʵÏÖ½Ó¿Ú£¬¿ÉÒÔ²»ÊµÏÖÆäÖеijéÏó·½·¨£¬¶ø½«³éÏó·½·¨µÄʵÏÖ½»¸¶¸ø¾ßÌåÄܱ»ÊµÀý»¯µÄÀàÈ¥´¦Àí¡£</p>
<textarea name="code" class="php">
<?php
interface User
{
function getName();
function setName($_name);
}
//´Ë´¦Ö»ÊÇʵÏÖÁËÒ»¸ö½Ó¿ÚµÄÒ»¸ö·½·¨
abstract class abatractNormalUser implements User
{
protected $name;
function getName() {
return $this->name;
}
}
//ÕâÀïʵÏÖÁ˽ӿڵÄÁíÍâÒ»¸ö·½·¨
class NormalUser extends abatractNormalUser
{
function setName($_name) {
$this->name = $_name;
}
}
$normaluser = new NormalUser();
$normaluser->setName("tom");
echo "name is " . $normaluser->getName();
?>
</textarea>
Ïà¹ØÎĵµ£º
0¡¢Óõ¥ÒýºÅ´úÌæË«ÒýºÅÀ´°üº¬×Ö·û´®£¬ÕâÑù×ö»á¸ü¿ìһЩ¡£ÒòΪPHP»áÔÚË«ÒýºÅ°üΧµÄ×Ö·û´®ÖÐËÑÑ°±äÁ¿£¬µ¥ÒýºÅÔò²»»á£¬×¢Ò⣺ֻÓÐechoÄÜÕâô×ö£¬ËüÊÇÒ»ÖÖ¿ÉÒ԰Ѷà¸ö×Ö·û´®µ±×÷²ÎÊýµÄ“º¯Êý”£¨Òë×¢£ºPHPÊÖ²áÖÐ˵echoÊÇÓïÑԽṹ£¬²»ÊÇÕæÕýµÄº¯Êý£¬¹Ê°Ñº¯Êý¼ÓÉÏÁËË«ÒýºÅ£©¡£
1¡¢Èç¹ûÄܽ«ÀàµÄ·½·¨¶¨Òå³Éstatic£¬¾Í¾¡ ......
ÀÏÉù³¤Ì¸£¬×ÅÊÇÀ§»óºÜ¶àÈ˵ÄÎÊÌ⣬Èç¹û´¦Àí²»ºÃ£¬¶¼ÊÇÂÒÂ룬˵ÕâЩ»°²¢²»ÊÇÎÒ¶Ô±àÂëºÜ¾«Í¨£¬Ö»ÊÇÔÚÕâ·½ÃæÊǵÃÁôÉñ£¬×Ô¼º×ܽáÁËÒ»µãС¾Ñé(ÈÝÒ׳öÏÖÂÒÂëµÄµØ·½ÓÐphpÎļþÀïÃ棬Êý¾Ý¿âÀïÃ棬ҳÃæÏÔʾ):
1.ÔÚÓÚÊý¾Ý´ò½»µÀµÄʱºòmysql_query("set names 'utf-8'");
2.ÔÚ½¨Êý¾Ý¿âµÄʱºò£¬ÓÈÆäÊÇÓÃphpMyAdminÓëMYSQL´ò½»µÀʱºò£¬ ......
Ò³ÃæµÄÖض¨Ïò£¬ËãÊǺܳ£ÓõŦÄÜÁË¡£ÏÂÃæժ¼³£ÓõÄ3ÖÖ·½·¨£º
<?php
¡¡¡¡if (isset($url))
¡¡¡¡{
¡¡¡¡Header("HTTP/1.1 303 See Other");
¡¡¡¡Header("Location: $url");
¡¡¡¡exit; //from www.kjsc.com.cn
¡¡¡¡}
¡¡¡¡?>
¡¡¡¡×¢Òâһϣ¬"Localtion:"ºóÃæÓÐÒ»¸ö¿Õ¸ñ¡£
¡¡¡¡¶ ......
PHP5ÖÐΪ½â¾ö±äÁ¿µÄÃüÃû³åÍ»ºÍ²»È·¶¨ÐÔÎÊÌ⣬ÒýÈë¹Ø¼ü×Ö“$this”´ú±íÆäËùÔÚµ±Ç°¶ÔÏó¡£
$thisÔÚ¹¹Ô캯ÊýÖÐÖ¸¸Ã¹¹Ô캯ÊýËù´´½¨µÄжÔÏó¡£
ÔÚÀàÖÐʹÓõ±Ç°¶ÔÏóµÄÊôÐԺͷ½·¨£¬±ØÐëʹÓÃ$this->È¡Öµ¡£
·½·¨Äڵľֲ¿±äÁ¿£¬²»ÊôÓÚ¶ÔÏ󣬲»Ê¹ÓÃ$this¹Ø¼ü×ÖÈ¡Öµ¡£
¾Ö²¿±äÁ¿ºÍÈ«¾Ö±äÁ¿Óë $this ¹Ø¼ü×Ö,ʹÓõ±Ç°¶ÔÏóµ ......
ÔÚPHP5ÀàÖмÌÐøʹÓÃconsÐÞÊγ£Á¿¡£ÎÒÃÇʹÓÃconst¶¨ÒåÒ»¸ö³£Á¿£¬¶¨ÒåµÄÕâ¸ö³£Á¿²»Äܱ»¸Ä±ä¡£ÔÚPHP5ÖÐconst¶¨ÒåµÄ³£Á¿Ó붨Òå±äÁ¿µÄ·½·¨²»Í¬£¬²»ÐèÒª¼Ó$ÐÞÊηû¡£ const PI = 3.14£» ÕâÑù¾Í¿ÉÒÔ¡£
¶øʹÓÃconst ¶¨ÒåµÄ³£Á¿Ãû³ÆÒ»°ã¶¼´óд£¬ÕâÊÇÒ»¸öÔ¼¶¨£¬ÔÚÈκÎÓïÑÔÖж¼ÊÇÕâÑù¡£
Èç¹û¶¨ÒåµÄ³£Á¿Óɶà¸öµ¥´Ê×é³É£¬Ê¹Óà _ Á¬½Ó£¬ ......