Nasty Parser Bug
| From: | Sterling Hughes | Date: | Wed, 02 Jul 2003 04:34:52 +0000 |
| Subject: | Nasty Parser Bug | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-3158@lists.php.net to get a copy of this message | ||
Hey,
Bug 24441 (http://bugs.php.net/bug.php?id=24441), displays the following
problem:
<?php
class test {
var $filter = 'hello';
var $array = array('hello', 'hello world', 'hey there');
function test() {
array_filter($this->array, array($this, 'filter'));
}
function filter ($value) {
return preg_match("/{$this->filter}/i", $value);
}
}
$t = new test;
var_dump($t->filter('hello world'));
?>
That script (also attached), will give an error:
Fatal error: Using $this when not in object context in
/data/home/sterling/work/os/php/php-src/arraybug.php on line 11
If you comment out the test() function declaration, everything will work
as expected.
-Sterling
--
"First they ignore you, then they laugh at you,
then they fight you, then you win."
- Gandhi
Attachment: [application/x-php] arraybug.php
Attachment: [application/x-php] arraybug.php