Last active
October 18, 2019 07:42
-
-
Save ERPedersen/72f59de9b068a8405b1bc2abe80a05cd to your computer and use it in GitHub Desktop.
Nullable foreach loop in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Initialize variable to null | |
$empty = null; | |
foreach ($empty ?? [] as $item) { | |
// Line never executed | |
} | |
// No error encountered |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment