1--TEST-- 2Test mb_ereg_replace() function : usage variations - <type here specifics of this variation> 3--INI-- 4error_reporting=E_ALL & ~E_NOTICE 5--SKIPIF-- 6<?php 7extension_loaded('mbstring') or die('skip'); 8function_exists('mb_ereg_replace') or die("skip mb_ereg_replace() is not available in this build"); 9?> 10--FILE-- 11<?php 12/* Prototype : proto string mb_ereg_replace(string pattern, string replacement, string string [, string option]) 13 * Description: Replace regular expression for multibyte string 14 * Source code: ext/mbstring/php_mbregex.c 15 * Alias to functions: 16 */ 17 18echo "*** Testing mb_ereg_replace() : usage variations ***\n"; 19 20// Initialise function arguments not being substituted (if any) 21$replacement = 'string_val'; 22$string = 'string_val'; 23$option = ''; 24 25//get an unset variable 26$unset_var = 10; 27unset ($unset_var); 28 29// get a class 30class classA 31{ 32 public function __toString() { 33 return "UTF-8"; 34 } 35} 36 37// heredoc string 38$heredoc = <<<EOT 39UTF-8 40EOT; 41 42// unexpected values to be passed to $encoding argument 43$inputs = array( 44 45 // int data 46/*1*/ 0, 47 1, 48 12345, 49 -2345, 50 51 // float data 52/*5*/ 10.5, 53 -10.5, 54 12.3456789000e10, 55 12.3456789000E-10, 56 .5, 57 58 // null data 59/*10*/ NULL, 60 null, 61 62 // boolean data 63/*12*/ true, 64 false, 65 TRUE, 66 FALSE, 67 68 // empty data 69/*16*/ "", 70 '', 71 72 // string data 73/*18*/ "UTF-8", 74 'UTF-8', 75 $heredoc, 76 77 // object data 78/*21*/ new classA(), 79 80 // undefined data 81/*22*/ @$undefined_var, 82 83 // unset data 84/*23*/ @$unset_var, 85 86); 87 88// loop through each element of the array for pattern 89 90$iterator = 1; 91foreach($inputs as $input) { 92 echo "\n-- Iteration $iterator --\n"; 93 var_dump( mb_ereg_replace($input, $replacement, $string, $option) ); 94 $iterator++; 95}; 96 97echo "Done"; 98?> 99--EXPECTF-- 100*** Testing mb_ereg_replace() : usage variations *** 101 102-- Iteration 1 -- 103 104Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 105string(10) "string_val" 106 107-- Iteration 2 -- 108 109Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 110string(10) "string_val" 111 112-- Iteration 3 -- 113 114Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 115string(10) "string_val" 116 117-- Iteration 4 -- 118 119Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 120 121Warning: mb_ereg_replace(): Pattern is not valid under UTF-8 encoding in %s on line %d 122bool(false) 123 124-- Iteration 5 -- 125 126Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 127string(10) "string_val" 128 129-- Iteration 6 -- 130 131Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 132 133Warning: mb_ereg_replace(): Pattern is not valid under UTF-8 encoding in %s on line %d 134bool(false) 135 136-- Iteration 7 -- 137 138Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 139string(10) "string_val" 140 141-- Iteration 8 -- 142 143Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 144string(10) "string_val" 145 146-- Iteration 9 -- 147 148Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 149string(10) "string_val" 150 151-- Iteration 10 -- 152 153Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 154string(10) "string_val" 155 156-- Iteration 11 -- 157 158Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 159string(10) "string_val" 160 161-- Iteration 12 -- 162 163Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 164string(10) "string_val" 165 166-- Iteration 13 -- 167 168Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 169string(10) "string_val" 170 171-- Iteration 14 -- 172 173Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 174string(10) "string_val" 175 176-- Iteration 15 -- 177 178Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 179string(10) "string_val" 180 181-- Iteration 16 -- 182string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val" 183 184-- Iteration 17 -- 185string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val" 186 187-- Iteration 18 -- 188string(10) "string_val" 189 190-- Iteration 19 -- 191string(10) "string_val" 192 193-- Iteration 20 -- 194string(10) "string_val" 195 196-- Iteration 21 -- 197 198Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 199string(10) "string_val" 200 201-- Iteration 22 -- 202 203Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 204string(10) "string_val" 205 206-- Iteration 23 -- 207 208Deprecated: mb_ereg_replace(): Non-string patterns will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d 209string(10) "string_val" 210Done 211