PHP ??? ??? ??? ???? ??? ?????. 1. ?? ?? ?? (SRP) : ? ???? ??? ?? ? ??? ????. 2. Open and Close Principle (OCP) : ??? ????? ??? ?? ?????. 3. Richter ?? ?? (LSP) : ?? ???? ???? ???? ??? ??? ?? ?? ???? ?? ? ? ????. 4. ????? ?? ?? (ISP) : ??? ? ???? ?? ??? ??? ?? ??? ?????? ??????. 5. ??? ?? ?? (DIP) : ?? ?? ??? ??? ???? ???? ??? ??? ?? ?????.
??
?????? ???? ??? ??? ??? ??? ??? ???? ?? ??? ????. ??? ??? ?? ?? ???? ?? ?? ? ??? ??? ? ?? ?? ??? ??? ?????? ?????????. ??? ??? ??? ??? ???? PHP ???? ?? ?? ????? ?? ? ????. ? ??? ?? ??? ??? ??? ??? ????? ??? ?? ????? ???? ??? ??? ????? ??? ??????.
?? ?? ??
??? ??? ?? ????? ?? ?? ?? ????? (OOP)? ?? ??? ??? ???. OOP? ??? ???? ??? ?? ??? ???? ???, ?? ? ???? ?? ??? ???? ?? ??? ? ???? ???? ????. PHP?? ??? ??? ???, ????? ? ??? ?? ????? ?? ?????.
?? ?? ?? ?? ??
??? ??? ?? ? ??
??? ??? Robert C. Martin? ??? 5 ?? ?? ?? ?? ??? ?????. ??? ??? ????.
- ?? ?? ?? (SRP) : ???? ??? ? ?? ??? ??????.
- OCP (Open/Closed Principle) : ????? ??? (???, ??, ?? ?)? ??? ??????? ???? ??????.
- Liskov ?? ?? (LSP) : ?? ???? ????? ???? ???? ?? ?? ???? ?? ? ? ??????.
- ????? ?? ?? (ISP) : ?????? ???? ?? ??? ????? ????.
- ??? ?? ?? (DIP) : ?? ??? ??? ??? ??? ????? ??? ? ? ???? ???????. ???? ?? ??? ????? ??? ?? ??? ???? ???????.
??? ??? ????? ???? ?? ??? ?? ???? ??? ???? ? ??????.
?? ??
??? ??? PHP ???? ??? ????? ?? ? ???.
?? ?? ?? (SRP)
SRP? ?? ????? ? ???? ??? ???? ??? ?? ??????? ????. ??? ??? ?? ??? ???? ?? ??? ??? ??? ?? ??? ??? ??? ? ???????.
// ?? : ???? ?? ??? ??? ????. ??? userManager { ?? ?? SaveUser (??? $ user) { // ??? ?? ??} public function sendemail (user $ user) { // ??? ?? ???} } // ??? ? ? : ? ???? ??? ?? ??? ?????. ?? ?? SaveUser (??? $ user) { // ??? ?? ??} } ??? ??? ??? { public function sendemail (user $ user) { // ??? ?? ???} }
?? ? ?? ?? (OCP)
OCP? ?? ??? ??????? ???? ?? ??? ????? ?????. ??? ?? ???? ?????? ???? ?? ? ? ????.
// CounterAmble : ?? ???? ?? ???? PaymentProcessor { ?? ?? ???? ?? (?? $ ??) { if ($ payment-> gettype () == 'Credit_card') { // ???? ?? ?? ??} elseif ($ payment-> getType () == 'payPal') { // Process PayPal ??} } } // ??? ? ? : ??? ?? OCP? ????? ????? paymentgateway { ?? ?? ???? (?? $ ??); } ??? ?? ?? ??? ??? ?? ??? ??? ?????. ?? ?? ???? (?? $ ??) { // ???? ?? ?? ??} } Class PayPalgateway? PaymentGateway? ?????. ?? ?? ???? (?? $ ??) { // Process PayPal ??} } Class PaymentProcessor { ?? $ ?????; ?? ?? __construct (PaymentGateway $ Gateway) { $ this-> ????? = $ ?????; } ?? ?? ???? ?? (?? $ ??) { $ this-> ?????-> ???? ($ payment); } }
Lisch ?? ?? (LSP)
LSP? ?? ???? ????? ???? ???? ??? ?? ???? ?? ? ? ?????? ?????. ?? ?? ???? ?? ???? ??? ??? ?? ?????.
// ?? : ?? ???? ?? ??? ??? ???? ??? ?????. ?? ? $ ??; ?? ? $ ??; ?? ?? setwidth ($ width) { $ this-> ?? = $ ??; } ?? ?? ?? ??? ($ ??) { $ this-> ?? = $ ??; } ?? ?? getArea () { $ this-> ?? * $ this-> ??; } } ??? ???? ???? ?????. ?? ?? setwidth ($ width) { $ this-> ?? = $ this-> height = $ width; } ?? ?? ?? ??? ($ ??) { $ this-> ?? = $ this-> height = $ ??; } } // $ rectangle = new Rectangle ()? ??? ? ??? ?????. $ rectangle-> setwidth (5); $ ???-> Setheight (10); echo $ ???-> getArea (); // ?? 50 $ square = new Square (); $ square-> setwidth (5); $ square-> setheight (10); echo $ square-> getArea (); // ?? 100, LSP ?? // ???? ? : ?????? ??? ?? LSP? ????? ????? ?? { ?? ?? getArea (); } ??? ???? ?? { ?? $ ??; ?? $ ??; ?? ?? __construct ($ ??, $ ??) { $ this-> ?? = $ ??; $ this-> ?? = $ ??; } ?? ?? getArea () { $ this-> ?? * $ this-> ??; } } ??? ???? ?? { ?? $ ??; ?? ?? __construct ($ side) { $ this-> side = $ side; } ?? ?? getArea () { $ this-> side * $ this-> side? ?????. } }
????? ?? ?? (ISP)
ISP? ??? ???? ?? ??? ????? ???? ?????. ??? ? ??? ?? ?????? ???? ?? ? ? ????.
// ?? : ?? ??? ????? ??? { ?? ?? ?? (); ?? ?? eat (); } ??? ??? ??? { ?? ?? ?? () { // ?? ?? ??} ?? ?? eat () { // ??? ?? ??? ???? ??? ???????} } // ??? ? ? : ISP? ??? ?????? ?? ????? ????? ?? ?? { ?? ?? ?? (); } ????? eatable { ?? ?? eat (); } ??? ??? ?? ???? ?? ??? { ?? ?? ?? () { // ?? ?? ??} ?? ?? eat () { // ?? ?? ??} } ??? ??? ?? ??? { ?? ?? ?? () { // ?? ?? ??} }
??? ?? ?? (DIP)
DIP? ?? ??? ??? ??? ??? ????? ??? ? ? ???? ??????? ?????. ??? ??? ??? ?? ?? ? ? ????.
// ?? : ?? ?? ??? ?? ?? ??? ????? ??? ??? ??? { ?? ?? getUserData () { $ database = new MySqlDatabase (); return $ database-> query ( 'select * from user'); } } // ??? ? ? : DIP? ??? ??? ?? ????? ????? ?????? { ?? ?? ?? ($ SQL); } ??? mysqldatabase? ?????? { ?? ?? ?? ($ SQL) { // mysql query logic} } ??? ??? ??? { ?? $ ??????; public function __construct (database $ database) { $ this-> ?????? = $ ??????; } ?? ?? getUserData () { $ this-> database-> query ( 'select * from user'); } }
??? ?
?? ??
?? ?????? ??? ??? ???? ?? ?? ? ??? ? ?? ??? ???? ? ??? ? ? ????. ?? ??, ?? ??? ????? ?? ??, ?? ?? ? ?? ??? ?? ???? ?? ? ? ????? ? ???? ??? ?? (SRP)?? ??? ????.
??? OrderProcessor { Public Function Processorder (?? $ ??) { // ?? ?? ??} } Class PaymentProcessor { ?? ?? ???? ?? (?? $ ??) { // ???? ?? ??} } ??? ???? ??? { Public Function UpdateInventory (Product $ ??, $ ??) { // ?? ?? ????} }
?? ??
?? ??? ??????? ??? ??? ???? ??? ? ????. ?? ??, ??? ?? ?????? ??? ? ?? ?? ? ??? ?? ??? ???? ?? ??? ??? ?? ???? ?? ? ? ????.
????? ?? ?? { ?? ?? render (); } Class TextContent? ContentType { ?? ?? render () { // ??? ??? ??} } Class ImageContent? ContentType { ?? ?? render () { // ??? ??? ???} } ??? ContentManager { ?? $ contenttypes; ?? ?? __construct (?? $ contenttypes) { $ this-> contentTypes = $ contentTypes; } ?? ?? RenderContent (Content $ ???) { foreach ($ this-> contenttypes as $ contenttype) { if ($ contenttype instanceof contenttype && $ contenttype-> supports ($ content)) { $ contenttype-> render ($ content)? ?????. } } ??? \ exception ( '???? ?? ??? ??')? ?????. } }
???? ?? ? ??? ?
??? ??? ?? ? ?? ???? ??? ??? ????.
- ??? ??? : ? ????? SRP? ???? ?????? ??? ?? ???? ???? ???? ???? ?????.
- ?? ?? ?? : ?? ??? ???? ??? ???? ?? ????? ??? ???? ???? ???? ?????.
??? ???? ??? ?????.
- ?? ?? : ?? ?? ??? ??? ??? ??? ??????? ?? ?????.
- ??? ?? ?? (TDD) : TDD? ?? ??? ???? ?? ?? ??????.
?? ??? ? ?? ??
??? ??? ?? ? ?? ?? ??? ? ?? ??? ???????.
- ?? ??? : ??? ??? ?? ?? ???? ????? ? ?????? ??? ?? ?? ??? ?? ? ? ????. ?? ??, ??? ??? ???? ?? ??? ?? ??? ?? ? ? ????. ? ?? ??? ?? ?? ?? ?????? ??? ?? ?? ?? ?? ??? ??? ??? ? ????.
// ? : ??? ?? ? ?? ??? ??? ???? ???? ??? ??????. ?? $ ??????; ?? $ ??; public function __construct (Database $ Database, Cache $ Cache) { $ this-> ?????? = $ ??????; $ this-> cache = $ cache; } ?? ?? getUserData ($ userID) { if ($ this-> cache-> was ($ userId)) { $ this-> cache-> get ($ userId); } $ data = $ this-> database-> query ( 'select * where id =?', [$ userId]); $ this-> cache-> set ($ userId, $ data); ?? $ ???; } }
- ?? ?? : ??? ??? ??? ??? ???? ?? ??????? ???????. ?? ??, ???? ?? ?? ??, ??? ?? ??, ??? ?? ??? ?? ?????.
? ??? ?? ??? ??? ??? ??? ??? ????? ??? ?? PHP ?? ??? ?? ?? ????? ?? ????? ?????. ? ??? ????? PHP ??? ??? ? ? ???? ?? ?? ???? ?? ? ??? ???? ???? ? ?????? ????.
? ??? ??? ??? PHP ??? ???? ??? ??????.? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











? ????? ???? ??? ?? ??? ????? ?? ?? ??? ???? ?? ??? ????. Memcache? ?? ??? ??? ??? ? ?? ?? ??? ? ????? ???? ?? ???? ?? ?????. ? ????? PHP ??? Memcache? ???? ??? ???? ???? ?? ??? ?????. 1. Memcache ?? Memcache? ????? ?? ??? Memcache ?? ????? ???? ???. CentOS ?? ????? ?? ??? ??? ? ????.

PHP ???? ??? ??? ???? ??? ?????. 1. ?? ?? ?? (SRP) : ? ???? ??? ?? ? ?????. 2. Open and Close Principle (OCP) : ??? ????? ??? ?? ?????. 3. Lisch? ?? ?? (LSP) : ?? ???? ???? ???? ??? ??? ?? ?? ???? ?? ? ? ????. 4. ????? ?? ?? (ISP) : ??? ? ???? ?? ??? ??? ?? ??? ?????? ??????. 5. ??? ?? ?? (DIP) : ?? ?? ??? ??? ???? ???? ??? ??? ?? ?????.

PHP ???? ?? ?? ? ?? ??? ???? ??? ?????? ???? ????? ??? ??? ???? ?? ????? ???? ?? ??? ?? ??? ?? ? ????? ????. ?? ????? ?? ??? ?? ??? ???? ????? ???? ?? ?? ???? ?????. PHP ???? Git ? SVN? ?? ????? ???? ?? ?? ?? ??? ??? ??? ? ????. ? ????? PHP ???? ?? ?? ? ?? ??? ?? ??? ??? ???? ??? ?????. ? ?? ??? ???? ?? ?? ???? ????.

PHP ???? ???? ??? ?? ? ??? ?? Memcache? ???? ??? ?????? ??? ??????? ???? ??? ?? ??? ??? ?? ?? ??? ?? ? ???? ????. PHP ????? ??? ??? ?? ??? ????? ?? ??? ?? ??? ???? ??? ????. ????? ???? ?? ?? ? ??? Memcache???. Memcache? ?????? ?? ??, ??? ??, ?? ??? ?? ???? ? ??? ? ?? ??? ?? ??? ?? ?? ??????. ???? ???? ??????

PHP? ???? ?? ???? ?? ??? ???? ??? ?????? ????? ??? ??? ?? ???? ?? ??? ?? ? ???? ???, ??? ???? ???? ?? ? ???? ????. ?????? ???? ??? ?? ???? ???? ?? ???????. ?? ??? ?? ??? ?? ??? ???? ??? ?? ????? ?? ???? ????. ???? ?? ???? ?? ??? ???? ?? PHP? ???? ??? ?????? 1. ?????? ?? ??, ?? ?? ???? ??? ??????? ???? ???. ? ?? ???? ???? ?? ????.

PHP ?? ? ??? ??? ????? ?? ??? ???? ??? ?????? ??? ??? ??? ?? ??? ??? ??? ??? ??? ?????. PHP ???? ??? ??? ??? ????? ??? ?????. ? ????? PHP ???? ??? ???? ??? ??? ????? ??? ???????. 1. ??? ??? ????? ?? ??? ???? ??: ??? ??????? ?? ???? ?? ??? ???? ?? ??? ?? ??? ??? ??? ?? ? ???? ???? ? ????. ?? ?? ??: ??? ???? ?? ??? ?? ? ????.

????? ??? ?????? ?? ???? ????? ???? ?? ??? ??? ?? ???? ??. ????? ?? ?? ??? ??? ???? ??? ???? ??? ?????. ???? PHP? ??? ?? ????? ????? ?? ?? ??? ??? ???? ???? 1. ??? ?? ??? ??? ?? ???? ?? ??? ?? ??? ? ??? ??? ?? ???? ????? ???. ????? ??? ?????? ?? ??? ???? ???. ?????? ???? ???? ???? ?? ?? ??? ??? ??? ?? ? ????. ?? ?? ????

??? ?? ???? ?? ??? ??? ???? ?? PHP? ???? ??? ?????? ?????? ????? ??? ??? ??? ???? ????? ???? ???? ?? ? ???? ????. ??? ?? ???? ?? ???? ? ?? ??? ????, ? ??? ?? ? ??? ??? ??? ??????. ??? ??? ???? ???? ???? ???? ??? ??? ????? ???? ?? ??? ??? ? ????. ? ????? PHP? ???? ??? ?? ???? ??? ??? ??? ???? ??? ?? ?????. ??, ???? ???? ?? ??? ???? ???? ???.
