PHP Tutorial: Generators and Iterators - Quick Guide

Поделиться
HTML-код
  • Опубликовано: 2 авг 2024
  • Generators and Iterators are two powerful features of PHP and other programming languages such as Java, Python, etc. In this tutorial video, I'll be covering the Generators and Iterators.
    This a quick guide, I'll be covering the basics, and how they can be used to make code more efficient and even more readable. After watching this video, you'll better understand these two features and you should be able to use them to your advantage!
    📺 Recommended
    --------------------------------------------------
    Top 5 Design Patterns in Software Engineering: • 5 Necessary Design Pat...
    PHP Fibers & Asynchronous: • PHP Fibers & Asynchron...
    PHP Generators & Iterators: • OPCache Benchmarks, Po...
    PHP 8.2 Whats New: • PHP 8.2: Is This the U...
    🧾 Timestamps
    --------------------------------------------------
    0:00 Intro - Generators&Iterators
    0:20 What are the Iterators and Iterables?
    0:44 The Iterator Interface | PHP
    1:21 Example: Iterator (Procedure) | PHP
    2:21 Example: Iterator (OOP) | PHP
    6:09 ArrayIterator in PHP
    6:20 Example: ArrayIterator
    7:34 Built-in Iterators in PHP
    7:41 Why To Use Iterators?
    8:08 Generators: Intro
    8:41 What is Really a Generator?
    9:43 Generator Object
    10:25 Example: Generator for PHP
    11:49 XRange Function | PHP
    12:14 Benchmark: XRange Function
    13:28 Generators: Outro
    13:47 Outro
    #php #generator #iterator #programming #development #backend #designpatterns #softwareengineer #tutorial #programmingtutorial #phptutorial #DeskNook

Комментарии • 9

  • @DeskNook
    @DeskNook  Год назад +2

    Here’s the GitHub repo containing the examples (source code) from this video:
    github.com/myaghobi/examples-generators-iterators

  • @sliceem88
    @sliceem88 Год назад

    Your are back ! Good to see you !

    • @DeskNook
      @DeskNook  Год назад +1

      Thanks, I'm a bit slow for videos but always around

  • @preeper_
    @preeper_ Год назад

    greate vid!

  • @mobinamahmudian2243
    @mobinamahmudian2243 Год назад

    💙awli

  • @karthikhebbar4485
    @karthikhebbar4485 Год назад

    at 6:02 , how did the $myIterator object started behaving like an array? am i missing something? please shade light on this.

    • @DeskNook
      @DeskNook  Год назад

      Check out 2:21 (Example: Iterator OOP)

  • @GonzaloMassa
    @GonzaloMassa Год назад

    So ArrayIterator won't check if current() is using a valid key, but your MyIterator class didn't check that and it worked with a foreach loop... what am I missing?

    • @DeskNook
      @DeskNook  Год назад

      For the current() function it will validate the current position of the key too
      For MyIterator which is an implementation of the Iterator interface, validity gonna check by valid() method, the same thing for ArrayIterator