SPL ????? ? ????? (? : ???, ??? ??, ArrayAccess)? ? ??????
Apr 04, 2025 am 12:01 AMSPL ??????? PHP? ???, ??? ?? ? ArrayAccess? ?????. 1. ??? ?????? ??? ???? ???? ??? current (), key (), next (), rewind () ? ??? () ???? ?????. 2. Countable ?????? ???? ??? ?? ?????? count () ???? ?? ? ? ????. 3. ArrayAccess ?????? ???? ??? ??? ? ??? ? ? ??? Arrays (), offsetexists (), offsetget (), offsetset () ? offsetunset () ???? ?????. ??? ?????? ?? ???? ?? ??? ??????.
??
SPL (?? PHP ?????) ?????? PHP ?????? ??? ?? ???, ????? ??? ?? ? ?? ??? ?? ? ??? ??? ? ??? ?????. ?? ??? SPL ??????? ???, ??? ?? ? ??? ??? ?? ?? ? ????. ? ??? ?? ??, ?? ?? ? ?? ??? ?? ???? ? ??? ???????. ????? ?? ? ?????, ??? ?????? ????? ?? ??? ?? ??? ?? ?????.
?? ?? ??
PHP?? ?????? ???? ?? ???? ?? ??? ???? ??????. SPL ?????? PHP ?? ?????? ???? ?? ??? ?? ? ??? ??? ? ??? ????? ???????. ??? ?????? ??? ?? ??? ??? ?????.
- ?? ? ??? : PHP? ??? ???? ???? ???? ??? ??? ??? ?????.
- ????? : ?????? ??? ??? ??? ???? ?????? ???? ???? ??? ???? ???????.
- ITERATOR : ITERATOR? ?? ??? ????? ?? ???? ??? ?? ? ??? ?? ?????.
?? ?? ?? ?? ??
??? ?????
?? ? ?? : ??? ?????? ?? ??? ???? ?? ?? ? ? ???? ??? Foreach ??? ??? ? ????. ?? ??? ?????.
????? ??? ?? ???? ?? { ?? ?? current (); ?? ?? ? (); ?? ?? ?? (); ?? ?? Rewind (); ?? ?? ??? (); }
?? ?? : Foreach? ???? Ierator ?????? ???? ??? ?? ??? ???? PHP? ???? ??? ??? ???? ???? ????? ?????. rewind () ???? ???? ???? ???? ????? ?? () ???? ???? ?? ??? ????, ?? () ???? ?? ??? ?? ????, ? () ???? ?? ??? ?? ???? ??? () ???? ?? ??? ???? ?????.
? :
??? myiterator? ???? ?????. ?? $ ?? = 0; private $ array = [ 'a', 'b', 'c']; ?? ?? __construct () { $ this-> ?? = 0; } ?? ?? Rewind () { $ this-> ?? = 0; } public function current () { $ this-> array [$ this-> position]; } ?? ?? ? () { $ this-> ??? ?????. } ?? ?? ?? () { $ this-> ??; } public function valid () { ?? ?? ($ this-> array [$ this-> position]); } } $ it = new myiterator (); foreach ($ as $ key => $ value) { echo "$ key : $ value \ n"; }
? ??? ?????
?? ? ?? : Countable ?????? ???? ??? ?? ? ?? ???? ? ? ????. ???? ?????.
????? ??? ?? { ?? ?? count (); }
?? ?? : Countable ?????? ???? ???? COUNT () ??? ???? PHP? ??? COUNT () ???? ???? ?? ?? ????.
? :
??? ?? ??? ??? ?? COUNTABLE { private $ array = [ 'a', 'b', 'c']; public function count () { ?? ? ($ this-> array); } } $ countable = new myCountable (); ?? ??? ($ countable); // ?? 3
ArrayAccess ?????
?? ? ?? : ArrayAccess ?????? ???? ??? ????? ??? ??? ? ????. ?? ??? ?????.
????? arrayaccess { ?? ?? offsetexists ($ offset); ?? ?? ??? ??? ($ ???); ?? ?? ??? ?? ($ ???, $ value); ?? ?? offsetunset ($ ???); }
?? ?? : ArrayAccess ?????? ???? ??? Square Bracket Syntax? ???? ?? ???? ????? ??? ? ????. OffSetExists () ??? ???? ????? ????, offsetget () ??? ???? ?? ???? offsetset () ???? ???? ?? ???? offsetunset () ???? ???? ?????.
? :
??? myArrayAccess? arrayAccess { ?? $ ???? = []; ?? ?? offsetexists ($ offset) { return isset ($ this-> ???? [$ offset]); } ?? ?? ??? get ($ ???) { $ this-> ???? [$ ???] ?? ?; } ?? ?? ??? ?? ($ ???, $ value) { if (is_null ($ offset)) { $ this-> ???? [] = $ ?; } ? ?? { $ this-> ???? [$ ???] = $ ?; } } ?? ?? offsetunset ($ offset) { unset ($ this-> ???? [$ offset]); } } $ arrayAccess = new MyArrayAccess (); $ arrayAccess [ 'key'] = 'value'; echo $ arrayaccess [ 'key']; // ?? ?
??? ?
?? ??
??? : ??? ?????? ???? ??? ?? ??? ?? ?? ? ? ????. ?? ??, ??? ?????? ???? ????? ???? ? ??? ??? ?? ??? ???? ??? ?????.
??? MyCollection? ??? { ?? $ ?? = []; ?? $ ?? = 0; ?? ?? ?? ($ item) { $ this-> ?? [] = $ ??; } ?? ?? Rewind () { $ this-> ?? = 0; } public function current () { $ this-> ?? [$ this-> position]; } ?? ?? ? () { $ this-> ??? ?????. } ?? ?? ?? () { $ this-> ??; } public function valid () { ?? ?? ($ this-> ?? [$ this-> position]); } } $ Collection = New MyCollection (); $ collection-> add ( 'item1'); $ collection-> add ( 'item2'); foreach ($ collection as $ item) { Echo $ ??. "\N"; }
COUNTEBLE : Countable ?????? ???? ??? ?? ? ?? ???? ? ? ????. ?? ??, Countable ?????? ???? ?? ???? ? ??? ??? ?? ?? ???? ??? ??????.
??? ????? ?? COUNTABLE { ?? $ ?? = []; ?? ?? ?? ($ item) { $ this-> ?? [] = $ ??; } public function count () { ?? ? ($ this-> ??); } } $ list = new MyList (); $ list-> add ( 'item1'); $ list-> add ( 'item2'); ?? ??? ($ list); // ?? 2
ArrayAccess : ArrayAccess ?????? ???? ??? ?? ??? ????? ??? ? ????. ?? ??, ??? ?? ?? ???? ??? ???? ArrayAccess ?????? ???? ???? ?? ? ? ????.
??? myDictionary ?? arrayAccess { ?? $ data = []; ?? ?? offsetexists ($ offset) { return isset ($ this-> data [$ offset]); } ?? ?? ??? get ($ ???) { $ this-> data [$ offset] ?? ?; } ?? ?? ??? ?? ($ ???, $ value) { if (is_null ($ offset)) { $ this-> data [] = $ value; } ? ?? { $ this-> data [$ ???] = $ ?; } } ?? ?? offsetunset ($ offset) { unset ($ this-> data [$ offset]); } } $ dict = new MyDictionary (); $ dict [ 'key'] = 'value'; echo $ dict [ 'key']; // ?? ?
?? ??
??? : ??? ????? ? ?? SPL ??? (? : Arrayiterator)? ?????? ??? ???? ??? ??? ? ????. ?? ??, ??? ??? ??? ??? ???? Arrayiterator? ???? ???? ????? ??? ? ? ????.
??? ComplexDatrastructure Implements iteratorAggregate { ?? $ data = [ 'key1'=> [ 'item1', 'item2'], 'key2'=> [ 'item3', 'item4'] ]; ?? ?? getiterator () { ? ?? ?? ($ this-> data)? ?????. } } $ ?? = ??? ComplexDatrastructure (); foreach ($ ?? $ key => $ value) { ?? "$ ? :". Implode ( ',', $ value). "\N"; }
COUNTABLE : Countable ????? ? ?? SPL ??? (? : CountableIterator)? ?????? ??? ?? ??? ??? ? ????. ?? ??, ?? ?? ?? ????? ???? ??? ???? CountableIterator? ???? ? ?? ?? ??? ? ????.
??? ?? ??? ?? COUNTABLE { ?? $ collections = []; ?? ?? AddCollection ($ Collection) { $ this-> collections [] = $ collection; } public function count () { $ ? = 0; foreach ($ this-> ????? $ collection) { $ total = count ($ collection); } ? $ ?; } } $ multicollection = ??? multicollection (); $ multicollection-> addCollection ([ 'item1', 'item2']); $ multicollection-> addCollection ([ 'item3', 'item4']); ?? ??? ($ multicollection); // ?? 4
ArrayAccess : ArrayAccess ????? ? ?? SPL ??? (? : ArrayObject)? ?????? ??? ?? ??? ??? ? ????. ?? ??, ??? ???? ???? ?? ???? ??? ??? ???? ArrayObject? ???? ??? ??? ? ? ????.
Class DynamicObject extends arrayoBject { ?? ?? __construct ($ input = []) { ?? :: __ ?? ($ ??); } } $ dynamicObject = new DynamicObject ([ 'key1'=> 'value1']); $ dynamicObject [ 'key2'] = 'value2'; echo $ dynamicobject [ 'key1']; // ?? ? 1 echo $ dynamicobject [ 'key2']; // value2? ????? unset ($ dynamicobject [ 'key1']); var_dump ($ dynamicobject); // key2 => value2? ?? arrayobject ??
???? ?? ? ??? ?
??? : ???? ???? ??? ??? ?? ?? ?? ??? ??? ???? ?? ?? ????. ?? ??, ??? () ???? ???? ?? ?? ??? Foreach ??? ??? ???? ????. ??? ??? var_dump () ?? print_r ()? ???? ? ??? ?? ?? ???? ???? ??????.
COUNTABLE : ???? ???? Count () ????? ??? ?? ????? ???? ???? ?? ?? ????. ??? ??? ???? ??? ?? ?? ??? ???? Count () ???? ??? ???? ??? ?? ????? ?????.
ArrayAccess : ???? ???? OffsetGet () ?? OffsetSet () ???? ??? ? ?? ??? ?????. ?? ??, ? ???? ???? ?? ?? ??? ??? ?? ??? ??? ? ????. ??? ??? var_dump () ?? print_r ()? ???? ? ??? ?? ? ??? ???? ???? ?????.
?? ??? ? ?? ??
?? ??? : SPL ?????? ???? ??? ??? ?? ?? ? ? ????. ?? ??, ??? ?????? ??? ???? ?? ? ????. ?? ???? ? ?????? ?? ???? ?????? ? ? ???? ??? ???? ?? ? ????. Countable ?????? ?? ?? ?? ???? ??? ???? ???? ??? ????. ArrayAccess ?????? ??? ????? ?? ?? ? ??? ? ????.
?? ?? : ?? ?? ??? ?? SPL ?????? ??? ? ?? ??? ???? ? ????.
- ?? ??? : ???? ?? ??? ??? ???? ??? ?? ???? ???????.
- ?? ?? : ?? ???? ????? ? ??? ?? ??? ??? ??????.
- ??? : ?? ???? ???? ??? ???? ???? ??? ??? ? ??? ???? ???????.
SPL ?????? ??????? ???? ??? ????? ??? ??? ?? ?? ? ?? ?? ???? ? ????. ?? ???? ??? ?????? ??? ??? ???? ?? ?? ???? ? ????.
? ??? SPL ????? ? ????? (? : ???, ??? ??, ArrayAccess)? ? ??????? ?? ?????. ??? ??? 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)

??? ??











??? ???? ?? ? ????? ???? ???? ?? ????? ???? ? ? ???? ?? ???? ?? ??? ?? ? ??? ??? ??? ???? ??? ??? ???? ???? ????? ?????. ??? ???? Php ?????? ECharts ?????? ???? ?? ???? ??? ?? ??? ???? ???? ? ??? ? ? ????. ? ????? Php ?????? ECharts ?????? ???? ??? ?? ??? ???? ??? ??? ?????. ???? ????? MySQL? ?????.

ECharts? PHP ?????? ?? ??? ?? ??? ???? ?? ???? ???? ??? ??? ???? ?? ??? ???? ??? ??? ?????. ??? ?? ?? JavaScript ??? ??? ?????? ECharts? ??? ?? ??? ???? ????? ???? ? ??? ???. ? ????? ECharts ? PHP ?????? ?? ??? ?? ??? ???? ??? ???? ?? ?? ??? ?????. 1. ?? ???? ?? ? ?? ??? ?? ???.

ECharts? PHP ?????? ???? ?? ??? ?? ????? ???? ?? ??: ??? ???? ?? ???????? ??? ??? ???. ECharts? ??? ??? ?? ??? ?? ???? ? ??? ?? ??? JavaScript ?? ????????. PHP? ??? ??? ?? ???? ???? ?????. ECharts? PHP ?????? ?????? ?? ??? ?? ????? ??? ? ???? ??? ???? ??? ???? ??? ???? ????? ? ????. ?

SPL ??????? PHP? ???, ??? ?? ? ArrayAccess? ?????. 1. ??? ?????? ??? ???? ???? ??? current (), key (), next (), rewind () ? ??? () ???? ?????. 2. Countable ?????? ???? ??? ?? ?????? count () ???? ?? ? ? ????. 3. ArrayAccess ?????? ???? ??? ??? ? ??? ? ? ??? Arrays (), offsetexists (), offsetget (), offsetset () ? offsetunset () ???? ?????. ??? ?????? ?? ???? ?? ??? ??????.

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

ECharts ? PHP ?????? ?? ??? ?? ? ?? ?? ??? ???? ?? ??? ???? ?? ??? ???? ?? ECharts? ?? ?? ?? ??? ??? ??? ?????. ???? ??? ???? ??? PHP? ? ???? ?? ?????. ? ????? ECharts ? PHP ?????? ?? ??? ?? ? ?? ?? ??? ???? ??? ???? ???? ?? ??? ?????. ?? EChart? ???? ???. ECharts? Baidu?? ??? ?? ?? ????????.

?? ????????? ??? ???? ?? ? ????? ????. ?? ??? ???? ????? ?? ???? ???? ??? ??? ?? ???? ? ??? ? ? ????. ECharts? ??? ?? ??? ??? ??? ???? ??? ????? ?? ????????. Php? ?? ???? ?????? ?? ??? ? ?? ??? ?? ?? ?? ??? ?????. ? ????? PHP ?????? ECharts? ???? ??? ?? ??? ???? ??? ???? ???? ?? ??? ?????. ??,

PHP ?????? ECharts? ???? ?? ??? ??? ???? ? ???? ????? ?? ?? ??? ?????. ??? ?????? ?? ??? ???? ?? ???? ???? ???? ?????. ?? ????? ??? ?? ??? ???? ?? ???? ???? ????? ?? ??? ????. PHP ?????? ECharts? ??? ??? ? ?? ?? ???? ???? ? ?? ???? ? ?? ?????. ??? ??? ???? PHP ????? ? ECharts ??? ???? ??? ?????.
