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>
Ïà¹ØÎĵµ£º
<?php
/*
Singleton && Registry Design Pattern Implementation
*/
class Registry {
private $_store = array();
public function getInstance() {
static $instance = array();
if (!$instance) {
$instance[0] = new ......
ÀÏÉù³¤Ì¸£¬×ÅÊÇÀ§»óºÜ¶àÈ˵ÄÎÊÌ⣬Èç¹û´¦Àí²»ºÃ£¬¶¼ÊÇÂÒÂ룬˵ÕâЩ»°²¢²»ÊÇÎÒ¶Ô±àÂëºÜ¾«Í¨£¬Ö»ÊÇÔÚÕâ·½ÃæÊǵÃÁôÉñ£¬×Ô¼º×ܽáÁËÒ»µãС¾Ñé(ÈÝÒ׳öÏÖÂÒÂëµÄµØ·½ÓÐphpÎļþÀïÃæ£¬Êý¾Ý¿âÀïÃæ£¬Ò³ÃæÏÔʾ):
1.ÔÚÓÚÊý¾Ý´ò½»µÀµÄʱºòmysql_query("set names 'utf-8'");
2.ÔÚ½¨Êý¾Ý¿âµÄʱºò£¬ÓÈÆäÊÇÓÃphpMyAdminÓëMYSQL´ò½»µÀʱºò£¬ ......
PHP5ÖÐʹÓÃparent::À´ÒýÓø¸ÀàµÄ·½·¨¡£ parent:: ¿ÉÓÃÓÚµ÷Óø¸ÀàÖж¨ÒåµÄ³ÉÔ±·½·¨¡£parent::µÄ×·Ëݲ»½öÓÚÖ±½Ó¸¸Àà¡£
ͨ¹ýparent::µ÷Óø¸Àà·½·¨
<!-- ÉùÃ÷Ò»¸öÔ±¹¤Àà,¾ÀíÀà¼Ì³Ð×ÔÔ±¹¤Àà -->
<?php
class employee
{
protected $sal = 3000;
public function getSal() {
$this->sal = $this-> ......
µ¥¼þģʽҪ½â¾öµÄÎÊÌâ¾ÍÊÇ“ÈçºÎÈÃÕâ¸öÀàÖ»ÓÐÒ»¸öʵÀý”¡£
ÎÒÃǵÄwebÓ¦ÓÃÖУ¬´óÁ¿Ê¹ÓÃÁËÊý¾Ý¿âÁ¬½Ó£¬Èç¹û·´¸´½¨Á¢ÓëÊý¾Ý¿âµÄÁ¬½Ó±ØÈ»ÏûºÄ¸ü¶àµÄϵͳ×ÊÔ´¡£
ÎÒÃÇÈçºÎ½â¾öÕâ¸öÎÊÌ⣬½¨Á¢Î¨Ò»µÄÊý¾Ý¿âÁ¬½ÓÊDZØÒªµÄ·½Ê½¡£
ÎÒÃÇÓÖÈçºÎÖªµÀÓëÕâ¸öÊý¾Ý¿âµÄÁ¬½ÓÊÇ·ñÒѾ½¨Á¢£¿ »¹ÊÇÐèÒªÏÖÔÚ½¨Á¢£¿
µ¥¼þģʽ¿ÉÒÔ½â¾öÕ ......