summaryrefslogtreecommitdiff
path: root/ext/pcre/tests/bug44214.phpt
blob: 90e4c86453d8e1909c4c3f3571b1fc30d8d72cd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--TEST--
Bug #44214 (crash with preg_replace_callback() and global variable)
--FILE--
<?php
$string = 'aaa bbb ccc ddd eee ccc aaa bbb';

$array = array();

function myCallBack( $match ) {
    global $array;
    $array[] = $match;
    return 'xxx';
}

var_dump(preg_replace_callback( '`a+`', 'myCallBack', $string));
var_dump($array);
?>
--EXPECT--
string(31) "xxx bbb ccc ddd eee ccc xxx bbb"
array(2) {
  [0]=>
  array(1) {
    [0]=>
    string(3) "aaa"
  }
  [1]=>
  array(1) {
    [0]=>
    string(3) "aaa"
  }
}