Skip to content

Chapter 23 of 38

PHP Standard Library

Navigate arrays, strings, math, dates, filters, iterators, and SPL structures.

42 minutes 10 quick checksBy Subha Prasad
Lesson 23 of 38Course navigation

Lesson content

Read, practise, then check your understanding

PHP's standard functions cover arrays, strings, math, dates, streams, filters, JSON, hashing, and more. SPL supplies iterators, exceptions, data structures, and autoload foundations.

Practical example

<?php
$numbers = [4, 1, 3];
sort($numbers, SORT_NUMERIC);
$when = new DateTimeImmutable('now', new DateTimeZone('UTC'));
$queue = new SplQueue();
$queue->enqueue('lesson');

Read signatures and failure semantics carefully because functions differ between false, null, warnings, and exceptions. Prefer DateTimeImmutable and explicit timezones. Use domain types where raw arrays and functions would scatter invariants.

Knowledge check

Answer every question correctly to complete this chapter.

Which statement best describes SPL?
Which PHP term matches this description: Core interfaces, iterators, data structures, and utility classes.
Which statement best describes array functions?
Which PHP term matches this description: Built-ins for mapping, filtering, sorting, reducing, and searching arrays.
Which statement best describes string functions?
Which PHP term matches this description: Built-ins for byte-string inspection and transformation.
Which statement best describes DateTimeImmutable?
Which PHP term matches this description: An immutable date-time value API.
Which statement best describes filter extension?
Which PHP term matches this description: Validation and sanitization helpers such as filter_var.

0 of 10 checks passed

Your progress is saved on this device.