Here, we are instantiating the SplDoublyLinkedList class, and testing the isEmpty and offsetExists methods. The output of the above code is:

IS EMPTY ON EMPTY
bool(true)
OFFSET EXISTS ON EMPTY
bool(false)

We can see the the isEmpty method returns true because we haven’t populated any items in our SplDoublyLinkedList. In addition to this, we can see that the offsetExists method is returning false for the same reason (because its empty).

Now, lets populate our list with some simple data and run these methods again:

Both of the above code blocks result in the same output:
0=>2
1=>3
2=>4

This reason that both of these are identical, is because the default iterator mode options are SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP. Nothing really new here, so lets explore some of the iterator options: