xref: /PHP-5.3/ext/pcre/tests/bug44214.phpt (revision 634fef42)
1--TEST--
2Bug #44214 (crash with preg_replace_callback() and global variable)
3--FILE--
4<?php
5$string = 'aaa bbb ccc ddd eee ccc aaa bbb';
6
7$array = array();
8
9function myCallBack( $match ) {
10    global $array;
11    $array[] = $match;
12    return 'xxx';
13}
14
15var_dump(preg_replace_callback( '`a+`', 'myCallBack', $string));
16var_dump($array);
17?>
18--EXPECT--
19string(31) "xxx bbb ccc ddd eee ccc xxx bbb"
20array(2) {
21  [0]=>
22  array(1) {
23    [0]=>
24    string(3) "aaa"
25  }
26  [1]=>
27  array(1) {
28    [0]=>
29    string(3) "aaa"
30  }
31}
32