Closures, built-in functions and objects

Scope and closures, the string and array function toolbox, and the first classes.

About 4 hours of study

Learning objectives

Lessons

  1. 1

    Scope and closures Intermediate

    Local and global scope, static variables, closures with use, arrow functions and callbacks.

  2. 2

    String and array functions Intermediate

    Map, filter, reduce and sort with callbacks, and the most useful string and array functions combined.

  3. 3

    Classes and objects Intermediate

    Classes, objects, properties and methods, constructors, visibility, static members, constants and copying objects.

Module practice

Module quiz

1. Can a normal function read a global variable directly?
2. Which function keeps only the items that pass a test?
3. What does use (&$total) do in a closure?
4. What does $this mean inside a method?
5. After $c = $a; where $a holds an object, what is true?
6. What should a usort callback return?

‹ Arrays and functionsObject design and complete programs ›