Directoryiterator / preg_match behavior

From: Date: Thu, 02 Sep 2004 00:33:10 +0000
Subject: Directoryiterator / preg_match behavior
Groups: php.internals 
Request: Send a blank email to internals+get-12530@lists.php.net to get a copy of this message
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

« previous php.internals (#12530) next »