Re: Directoryiterator / preg_match behavior
| From: | Curt Zirzow | Date: | Sat, 04 Sep 2004 03:46:15 +0000 |
| Subject: | Re: Directoryiterator / preg_match behavior | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-12571@lists.php.net to get a copy of this message | ||
* Thus wrote Andi Gutmans:
> It probably makes sense to add SEPARATE_ZVAL_IF_NOT_REF() to that code.
> This would provide the same behavior as for example for long's.
> Can you please check out the following patch?
Nice! That fixed the $file holding the value between iterations
Test 1: ($file now is reset on iteration)
<?php
foreach (new DirectoryIterator('.') as $file) {
echo "\n--\n";
var_dump($file);
preg_match("/xxx/", $file);
var_dump($file);
echo "--";
}
--
object(DirectoryIterator)#1 (0) {
}
string(1) "."
--
--
object(DirectoryIterator)#1 (0) {
}
string(2) ".."
--
What are the possibilities of thrown E_STRICT or E_WARNING, since
the object gets lost? Or should this simply be a documented
behaviour? If possible, any pointers where to consider applying them
at?
From what I've seen there are a lot of convert_to_xxx_ex()'s around
and can cause a some of unexpected results, without some sort of
notice. Of course ideally, an attempt to fetch a __toString()
value would be really nice :) I'm way over my head at this point.
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!