PHPÖÐÉè¼ÆģʽµÄѧϰ±Ê¼Ç
PHPÖÐÉè¼ÆģʽµÄѧϰ±Ê¼Ç
Éè¼Æģʽ(Design Pattern)ÊÇÃæÏò¶ÔÏóÉè¼ÆÖз´¸´³öÏÖµÄÎÊÌâµÄ½â¾ö·½°¸£¬Éè¼ÆģʽÊÇÒ»ÖÖ±ÈÒ»°ãÀàµÄÉè¼Æ¸ü¼Ó³éÏóµÄÒ»ÖÖ˼Ï룬
ËüÍùÍùÉæ¼°µ½¶à¸öÀàµÄ¶¨ÒåºÍʹÓá£
ÔÚPHPµÄ¿ª·¢¹ý³ÌÖУ¬¾³£Ê¹Óõ½µÃÉè¼Æģʽ°üÀ¨£º¼òµ¥¹¤³§Ä£Ê½¡¢µ¥ÔªËØģʽ¡¢¹Û²ìÕßģʽ¡¢ÃüÁîģʽ¡¢²ßÂÔģʽÒÔ¼°MVCģʽµÈ¡£
/**
* ¼òµ¥¹¤³§Ä£Ê½(Simple Factory Pattern),¾ßÌåÖ¸´´½¨Ò»¸öÀàËÆÓÚ¹¤³§µÄÀ࣬ͨ¹ý¶ÔÀàÖгÉÔ±·½·¨µÄµ÷Ó÷µ»Ø²»Í¬µÄ¶ÔÏó
* ¸ÃģʽµÄºËÐÄÊǹ¤³§À࣬¸ÃÀàÖк¬ÓбØÒªµÄÅжÏÂß¼£¬¿ÉÒÔ¾ö¶¨ÔÚʲôʱºò´´½¨²¢·µ»ØÄĸö²úÆ·µÄʵÀý»¯¶ÔÏó
*/
//¶¨Òå³éÏóÀàProduct
abstract class Product
{
abstract function getName();
}
//¶¨Òå¾ßÌå²úÆ·ÀàA
class ProductA extends Product
{
public function getName()
{
echo "I am product A";
}
}
//¶¨Òå¾ßÌå²úÆ·ÀàB
class ProductB extends Product
{
public function getName()
{
echo "I am product B";
}
}
//¶¨Ò幤³§Àà
class ProductFactory
{
static function create($name)
{
switch($name)
{
case "A":
return new ProductA();
case "B":
return new ProductB();
}
}
}
$product=ProductFactory::create("A");
$product->getName();
echo "<br/>";
$product=ProductFactory::create("B");
$product->getName();
/**
* µ¥ÔªËØģʽ(Singleton Pattern)ÊÇÖ¸¶ÔÖ¸¶¨µÄÀàÖ»ÄÜʵÀý»¯Ò»´Î¡£
* ¸Ãģʽͨ³£°üº¬Ò»¸ö˽Óй¹Ôì·½·¨£¬ÓÃÀ´È·±£ÎÞ·¨Í¨¹ý´´½¨¶ÔÏó»òÕß¿Ë¡µÄ·½Ê½¶ÔÆä½øÐÐʵÀý»¯
* ¸Ãģʽ»¹°üº¬ÓÐÒ»¸ö˽Óо²Ì¬ÊôÐԺ͹«Óо²Ì¬·½·¨¡£
* ¹«Óо²Ì¬·½·¨¸ºÔð¶ÔÆä±¾Éí½øÐÐʵÀý»¯£¬¶ø˽Óо²Ì¬ÊôÐÔ¸ºÔð´æ´¢ÊµÀý»¯µÄ¶ÔÏó¡£
*/
class Singleton
{
private static $ins
Ïà¹ØÎĵµ£º
Éϴμ̱¾ÈË·¢²¼ÁËVC±àдPHPÀ©Õ¹Ö®Hello Worldƪºó£¬·´Ó³ºÜÇ¿ÁÒ£¬´ó¼Ò¶¼Ï£ÍûÄÜÍÑÀëPHP²ËÄñÐÐÁУ¬Õâ´ÎÎÒ¸ø´ó¼Ò´øÀ´PHPµ÷ÓÃC#±àдµÄCOM+×é¼þ¡£ COM+×é¼þÔ´´úÂë CODE:using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Reflection; using System.Data.O ......
[part1] http://download.csdn.net/source/2076258
[part2] http://download.csdn.net/source/2076272
[part3] http://download.csdn.net/source/2076276
[part4] http://download.csdn.net/source/2076283
[part02-04] http://www.ytgps.com/Images/nginx.rar
±¾ÎļþÌå»ý¹ý´ó·Ö4¸ö°ü£¬php-cgi+mysql+nginx.7z ......
ÔÚPHPÖÐʹÓÃÍ·Îļþ£¬»áÉæ¼°Á½¸öº¯Êý£ºinclude()ºÍrequire()¡£ÕâÁ½¸öº¯Êý²î±ðºÜС£¬È´ºÜÖØÒª£¬ËùÒÔÎÒÃÇÒªÈÏÕæÑо¿Ò»Ï¡£
require()º¯Êý¹¤×÷·½Ê½ÓëXSSIÏàÀàËÆ£»²»¹ÜÔÚ³ÌÐòµÄÄĸö²¿·ÖʹÓÃÁËÕâ¸öº¯Êý£¬Ö»ÓгÌÐòÒ»¿ªÊ¼ÔËÐУ¬Í·ÎļþµÄÄÚÈݾͱ»×÷Ϊ³ÌÐò±¾ÉíµÄÒ»²¿·ÖÀ´´¦
Àí¡£Òò´Ë£¬Èç¹ûÄúÔÚÒ»¸öÌõ¼þÅж¨Óï¾äÖÐʹÓÃÁËrequire()º¯Ê ......
½ñÌìÍ·ÄÔÒ»ÈÈ£¬Ïë¿´Ò»ÏÂÒ³ÃæÔÚÖ´ÐеĹý³ÌÖÐÕ¼ÓÃÁ˶àÉÙÄڴ棬ÎÒÒ²²»ÖªµÀÕâÑù×öµÄÄ¿µÄÊÇʲô£¬¿ÉÄÜÊdzöÓÚÎҵĹßÐÔ˼ά°É¡£²»¹ýÕâÑù×öÒ²²»ÊÇÍêȫûÓã¬
Äã¿ÉÒÔÇå³þµÄÖªµÀÄÄЩҳÃæÕ¼ÓõÄÄÚ´æ±È½Ï¶à£¬ÌرðÊǶÔÓÚʹÓù²ÓÃÖ÷»úµÄÍøÕ¾£¬Ò»°ã¿Õ¼äÉ̶¼»áÏÞÖÆÿ¸öÍøÕ¾µÄ×ÊÔ´Õ¼ÓÃÇé¿öµÄ£¨°üÀ¨cpuºÍÄڴ棩¡£ÍòÒ»ÔÚÎÒ
ÃDz»ÖªµÀµÄÇé¿öÏ£ ......
0¡¢Óõ¥ÒýºÅ´úÌæË«ÒýºÅÀ´°üº¬×Ö·û´®£¬ÕâÑù×ö»á¸ü¿ìһЩ¡£ÒòΪPHP»áÔÚË«ÒýºÅ°üΧµÄ×Ö·û´®ÖÐËÑÑ°±äÁ¿£¬µ¥ÒýºÅÔò²»»á£¬×¢Ò⣺ֻÓÐechoÄÜÕâô
×ö£¬ËüÊÇÒ»ÖÖ¿ÉÒ԰Ѷà¸ö×Ö·û´®µ±×÷²ÎÊýµÄ“º¯Êý”(Òë×¢£ºPHPÊÖ²áÖÐ˵echoÊÇÓïÑԽṹ£¬²»ÊÇÕæÕýµÄº¯Êý£¬¹Ê°Ñº¯Êý¼ÓÉÏÁËË«ÒýºÅ)¡£
¡¡¡¡1¡¢Èç¹ûÄܽ«ÀàµÄ·½·¨¶¨Òå³Éstatic£¬¾Í ......