What is the SPL (Standard PHP Library)?
Why Interviewers Ask This
This question targets practical, hands-on experience with PHP. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.
Answer
The Standard PHP Library (SPL) is a collection of built-in interfaces and classes for common data structures, iterators, and utilities. Data structures: SplStack, SplQueue, SplDoublyLinkedList, SplPriorityQueue, SplMinHeap, SplMaxHeap, SplFixedArray (memory-efficient fixed-size array). Iterators: DirectoryIterator, RecursiveDirectoryIterator, FilesystemIterator, ArrayIterator, LimitIterator. Exceptions: RuntimeException, InvalidArgumentException, LogicException. Patterns: Countable, Serializable, ArrayAccess (use object like an array), Stringable. SPL is part of PHP core and requires no installation.
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a PHP codebase.