split_variation_001.phpt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. --TEST--
  2. Test split() function : usage variations - unexpected type for arg 1
  3. --FILE--
  4. <?php
  5. /* Prototype : proto array split(string pattern, string string [, int limit])
  6. * Description: Split string into array by regular expression
  7. * Source code: ext/standard/reg.c
  8. * Alias to functions:
  9. */
  10. function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
  11. echo "Error: $err_no - $err_msg, $filename($linenum)\n";
  12. }
  13. set_error_handler('test_error_handler');
  14. echo "*** Testing split() : usage variations ***\n";
  15. // Initialise function arguments not being substituted (if any)
  16. $string = '1 a 1 Array 1 c ';
  17. $limit = 5;
  18. //get an unset variable
  19. $unset_var = 10;
  20. unset ($unset_var);
  21. //array of values to iterate over
  22. $values = array(
  23. // int data
  24. 0,
  25. 1,
  26. 12345,
  27. -2345,
  28. // float data
  29. 10.5,
  30. -10.5,
  31. 10.1234567e10,
  32. 10.7654321E-10,
  33. .5,
  34. // array data
  35. array(),
  36. array(0),
  37. array(1),
  38. array(1, 2),
  39. array('color' => 'red', 'item' => 'pen'),
  40. // null data
  41. NULL,
  42. null,
  43. // boolean data
  44. true,
  45. false,
  46. TRUE,
  47. FALSE,
  48. // empty data
  49. "",
  50. '',
  51. // object data
  52. new stdclass(),
  53. // undefined data
  54. $undefined_var,
  55. // unset data
  56. $unset_var,
  57. );
  58. // loop through each element of the array for pattern
  59. foreach($values as $value) {
  60. echo "\nArg value $value \n";
  61. var_dump( split($value, $string, $limit) );
  62. };
  63. echo "Done";
  64. ?>
  65. --EXPECTF--
  66. *** Testing split() : usage variations ***
  67. Error: 8 - Undefined variable: undefined_var, %s(64)
  68. Error: 8 - Undefined variable: unset_var, %s(67)
  69. Arg value 0
  70. Error: 8192 - Function split() is deprecated, %s(74)
  71. array(1) {
  72. [0]=>
  73. string(16) "1 a 1 Array 1 c "
  74. }
  75. Arg value 1
  76. Error: 8192 - Function split() is deprecated, %s(74)
  77. array(4) {
  78. [0]=>
  79. string(0) ""
  80. [1]=>
  81. string(3) " a "
  82. [2]=>
  83. string(7) " Array "
  84. [3]=>
  85. string(3) " c "
  86. }
  87. Arg value 12345
  88. Error: 8192 - Function split() is deprecated, %s(74)
  89. array(1) {
  90. [0]=>
  91. string(16) "1 a 1 Array 1 c "
  92. }
  93. Arg value -2345
  94. Error: 8192 - Function split() is deprecated, %s(74)
  95. array(1) {
  96. [0]=>
  97. string(16) "1 a 1 Array 1 c "
  98. }
  99. Arg value 10.5
  100. Error: 8192 - Function split() is deprecated, %s(74)
  101. array(1) {
  102. [0]=>
  103. string(16) "1 a 1 Array 1 c "
  104. }
  105. Arg value -10.5
  106. Error: 8192 - Function split() is deprecated, %s(74)
  107. array(1) {
  108. [0]=>
  109. string(16) "1 a 1 Array 1 c "
  110. }
  111. Arg value 101234567000
  112. Error: 8192 - Function split() is deprecated, %s(74)
  113. array(1) {
  114. [0]=>
  115. string(16) "1 a 1 Array 1 c "
  116. }
  117. Arg value 1.07654321E-9
  118. Error: 8192 - Function split() is deprecated, %s(74)
  119. array(1) {
  120. [0]=>
  121. string(16) "1 a 1 Array 1 c "
  122. }
  123. Arg value 0.5
  124. Error: 8192 - Function split() is deprecated, %s(74)
  125. array(1) {
  126. [0]=>
  127. string(16) "1 a 1 Array 1 c "
  128. }
  129. Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d)
  130. Arg value Array
  131. Error: 8192 - Function split() is deprecated, %s(74)
  132. Error: 2 - split() expects parameter 1 to be string, array given, %s(74)
  133. NULL
  134. Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d)
  135. Arg value Array
  136. Error: 8192 - Function split() is deprecated, %s(74)
  137. Error: 2 - split() expects parameter 1 to be string, array given, %s(74)
  138. NULL
  139. Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d)
  140. Arg value Array
  141. Error: 8192 - Function split() is deprecated, %s(74)
  142. Error: 2 - split() expects parameter 1 to be string, array given, %s(74)
  143. NULL
  144. Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d)
  145. Arg value Array
  146. Error: 8192 - Function split() is deprecated, %s(74)
  147. Error: 2 - split() expects parameter 1 to be string, array given, %s(74)
  148. NULL
  149. Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d)
  150. Arg value Array
  151. Error: 8192 - Function split() is deprecated, %s(74)
  152. Error: 2 - split() expects parameter 1 to be string, array given, %s(74)
  153. NULL
  154. Arg value
  155. Error: 8192 - Function split() is deprecated, %s(74)
  156. Error: 2 - split(): REG_EMPTY, %s(74)
  157. bool(false)
  158. Arg value
  159. Error: 8192 - Function split() is deprecated, %s(74)
  160. Error: 2 - split(): REG_EMPTY, %s(74)
  161. bool(false)
  162. Arg value 1
  163. Error: 8192 - Function split() is deprecated, %s(74)
  164. array(4) {
  165. [0]=>
  166. string(0) ""
  167. [1]=>
  168. string(3) " a "
  169. [2]=>
  170. string(7) " Array "
  171. [3]=>
  172. string(3) " c "
  173. }
  174. Arg value
  175. Error: 8192 - Function split() is deprecated, %s(74)
  176. Error: 2 - split(): REG_EMPTY, %s(74)
  177. bool(false)
  178. Arg value 1
  179. Error: 8192 - Function split() is deprecated, %s(74)
  180. array(4) {
  181. [0]=>
  182. string(0) ""
  183. [1]=>
  184. string(3) " a "
  185. [2]=>
  186. string(7) " Array "
  187. [3]=>
  188. string(3) " c "
  189. }
  190. Arg value
  191. Error: 8192 - Function split() is deprecated, %s(74)
  192. Error: 2 - split(): REG_EMPTY, %s(74)
  193. bool(false)
  194. Arg value
  195. Error: 8192 - Function split() is deprecated, %s(74)
  196. Error: 2 - split(): REG_EMPTY, %s(74)
  197. bool(false)
  198. Arg value
  199. Error: 8192 - Function split() is deprecated, %s(74)
  200. Error: 2 - split(): REG_EMPTY, %s(74)
  201. bool(false)
  202. Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
  203. Arg value
  204. Error: 8192 - Function split() is deprecated, %s(74)
  205. Error: 2 - split() expects parameter 1 to be string, object given, %s(74)
  206. NULL
  207. Arg value
  208. Error: 8192 - Function split() is deprecated, %s(74)
  209. Error: 2 - split(): REG_EMPTY, %s(74)
  210. bool(false)
  211. Arg value
  212. Error: 8192 - Function split() is deprecated, %s(74)
  213. Error: 2 - split(): REG_EMPTY, %s(74)
  214. bool(false)
  215. Done