Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12530 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99566 invoked by uid 1010); 1 Sep 2004 15:32:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 97080 invoked from network); 1 Sep 2004 15:32:21 -0000 Received: from unknown (HELO deprecated.info) (212.13.208.104) by pb1.pair.com with SMTP; 1 Sep 2004 15:32:21 -0000 Received: from p5080f657.dip0.t-ipconnect.de ([80.128.246.87] helo=[192.168.122.254]) by deprecated.info with asmtp (Exim 4.34) id 1C2X5w-0007iG-7w for internals@lists.php.net; Wed, 01 Sep 2004 17:32:20 +0200 Message-ID: <41366A46.60502@wormus.com> Date: Wed, 01 Sep 2004 17:33:10 -0700 User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Directoryiterator / preg_match behavior From: aaron@wormus.com (Aaron Wormus) When playing with PHP5 I tried the following code: foreach (new DirectoryIterator('.') as $file) { if (preg_match("/^\./", $file)){ continue; } print "$file
\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 "
";
     var_dump($file);

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

     var_dump($file);
     echo "
"; } 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