1.2.804. No Direct Usage Of Returned Value

The results of the following functions shouldn’t be used directly, but checked first.

For example, glob() returns an array, unless an error happens, in which case it returns false. In such case, however rare it is, plugging glob() directly in a foreach() loops yields errors.

<?php
    // Used without check :
    foreach(glob('.') as $file) { /* do Something */ }.

    // Used without check :
    $files = glob('.');
    if (!is_array($files)) {
        foreach($files as $file) { /* do Something */ }.
    }
?>