When playing with PHP5 I tried the following code:

foreach (new DirectoryIterator('.') as $file) {
    if (preg_match("/^\./", $file)){
        continue;
    }
    print "<a href='$file'>$file</a><br />\n";
}

the result was unexpected, but after an IRC session and reading the manual all became clear.

My question is if the following code is the expected behaviour? I'm running E_STRICT and would expect at least a warning...

foreach (new DirectoryIterator('.') as $file) {
    echo "<pre>";
    var_dump($file);

    if (preg_match("/xxx/", $file)){
        // Why is this breaking $file??
        //    without even a warning
    }

    var_dump($file);
    echo "</pre>";
}

strpos and substr work fine, and I was kindly informed that they do a convert_to_string_ex() on the object before they do their thing. Would it be breaking anything if, for consistancy, the same functionality was put into preg_match?

I'm all sorted out now but thought to send this off incase it was indeed a bug somewhere.

Thanks

Aaron

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to