#32192 [Opn]: preg_grep & GLOBALS

From: Date: Fri, 04 Mar 2005 17:22:26 +0000
Subject: #32192 [Opn]: preg_grep & GLOBALS
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-74840@lists.php.net to get a copy of this message
ID: 32192 Updated by: tony2001@php.net Reported By: bolk at hitv dot ru Status: Open Bug Type: PCRE related Operating System: Linux RH 9 and Windows XP PHP Version: 5.0.3 New Comment: That's because $GLOBALS contains reference to itself. So I'd call this kinda expected behaviour. See this code: <?php $a = Array(); $a[] = &$a; preg_grep('/^T_/', $a); var_dump($a); ?> Previous Comments: ------------------------------------------------------------------------ [2005-03-04 17:55:03] bolk at hitv dot ru "damages". Sorry. ------------------------------------------------------------------------ [2005-03-04 17:23:03] bolk at hitv dot ru Description: ------------ preg_grep damage GLOBALS Bug in PHP 4.3.10 and 5.0.3 Reproduce code: --------------- <? preg_grep('/^T_/', $GLOBALS); var_dump($GLOBALS); ?> Expected result: ---------------- array(16) { ["argv"]=> array(1) { [0]=> string(5) "a.php" } ["argc"]=> int(1) ["HTTP_POST_VARS"]=> array(0) { } ["_POST"]=> array(0) { } ["HTTP_GET_VARS"]=> array(0) { } ["_GET"]=> array(0) { } ["HTTP_COOKIE_VARS"]=> array(0) { } ["_COOKIE"]=> array(0) { } ["HTTP_SERVER_VARS"]=> etceteras Actual result: -------------- string(5) "Array" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32192&edit=1

« previous php.bugs (#74840) next »