xref: /PHP-5.4/ext/pcre/tests/bug37800.phpt (revision c3ed9147)
1--TEST--
2Bug #37800 (preg_replace() limit parameter odd behaviour)
3--FILE--
4<?php
5$s_string = '1111111111';
6$s_search = '/1/';
7$s_replace = 'One ';
8$i_limit = 1;
9$i_count = 0;
10
11$s_output = preg_replace($s_search, $s_replace, $s_string, $i_limit,
12$i_count);
13echo "Output = " . var_export($s_output, True) . "\n";
14echo "Count  = $i_count\n";
15var_dump(preg_last_error() === PREG_NO_ERROR);
16
17$i_limit = strlen($s_string);
18$s_output = preg_replace($s_search, $s_replace, $s_string, $i_limit,
19$i_count);
20echo "Output = " . var_export($s_output, True) . "\n";
21echo "Count  = $i_count\n";
22var_dump(preg_last_error() === PREG_NO_ERROR);
23
24?>
25--EXPECT--
26Output = 'One 111111111'
27Count  = 1
28bool(true)
29Output = 'One One One One One One One One One One '
30Count  = 10
31bool(true)
32