1--TEST--
2Test mb_ereg_replace() function : usage variations  - <type here specifics of this variation>
3--INI--
4error_reporting=E_ALL & ~E_NOTICE
5--EXTENSIONS--
6mbstring
7--SKIPIF--
8<?php
9function_exists('mb_ereg_replace') or die("skip mb_ereg_replace() is not available in this build");
10?>
11--FILE--
12<?php
13echo "*** Testing mb_ereg_replace() : usage variations ***\n";
14
15// Initialise function arguments not being substituted (if any)
16$replacement = 'string_val';
17$string = 'string_val';
18$option = '';
19
20// get a class
21class classA
22{
23  public function __toString() {
24    return "UTF-8";
25  }
26}
27
28// heredoc string
29$heredoc = <<<EOT
30UTF-8
31EOT;
32
33// unexpected values to be passed to $encoding argument
34$inputs = array(
35
36       // int data
37/*1*/  0,
38       1,
39       12345,
40       -2345,
41
42       // float data
43/*5*/  10.5,
44       -10.5,
45       12.3456789000e10,
46       12.3456789000E-10,
47       .5,
48
49       // boolean data
50/*12*/ true,
51       false,
52       TRUE,
53       FALSE,
54
55       // empty data
56/*16*/ "",
57       '',
58
59       // string data
60/*18*/ "UTF-8",
61       'UTF-8',
62       $heredoc,
63
64       // object data
65/*21*/ new classA(),
66
67);
68
69// loop through each element of the array for pattern
70
71$iterator = 1;
72foreach($inputs as $input) {
73      echo "\n-- Iteration $iterator --\n";
74      var_dump( mb_ereg_replace($input, $replacement, $string, $option) );
75      $iterator++;
76};
77
78echo "Done";
79?>
80--EXPECT--
81*** Testing mb_ereg_replace() : usage variations ***
82
83-- Iteration 1 --
84string(10) "string_val"
85
86-- Iteration 2 --
87string(10) "string_val"
88
89-- Iteration 3 --
90string(10) "string_val"
91
92-- Iteration 4 --
93string(10) "string_val"
94
95-- Iteration 5 --
96string(10) "string_val"
97
98-- Iteration 6 --
99string(10) "string_val"
100
101-- Iteration 7 --
102string(10) "string_val"
103
104-- Iteration 8 --
105string(10) "string_val"
106
107-- Iteration 9 --
108string(10) "string_val"
109
110-- Iteration 10 --
111string(10) "string_val"
112
113-- Iteration 11 --
114string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
115
116-- Iteration 12 --
117string(10) "string_val"
118
119-- Iteration 13 --
120string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
121
122-- Iteration 14 --
123string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
124
125-- Iteration 15 --
126string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
127
128-- Iteration 16 --
129string(10) "string_val"
130
131-- Iteration 17 --
132string(10) "string_val"
133
134-- Iteration 18 --
135string(10) "string_val"
136
137-- Iteration 19 --
138string(10) "string_val"
139Done
140