split_variation_002.phpt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. --TEST--
  2. Test split() function : usage variations - unexpected type for arg 2
  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. $pattern = 'r|j|E';
  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 string
  59. foreach($values as $value) {
  60. echo "\nArg value $value \n";
  61. var_dump( split($pattern, $value, $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(1) "0"
  74. }
  75. Arg value 1
  76. Error: 8192 - Function split() is deprecated, %s(74)
  77. array(1) {
  78. [0]=>
  79. string(1) "1"
  80. }
  81. Arg value 12345
  82. Error: 8192 - Function split() is deprecated, %s(74)
  83. array(1) {
  84. [0]=>
  85. string(5) "12345"
  86. }
  87. Arg value -2345
  88. Error: 8192 - Function split() is deprecated, %s(74)
  89. array(1) {
  90. [0]=>
  91. string(5) "-2345"
  92. }
  93. Arg value 10.5
  94. Error: 8192 - Function split() is deprecated, %s(74)
  95. array(1) {
  96. [0]=>
  97. string(4) "10.5"
  98. }
  99. Arg value -10.5
  100. Error: 8192 - Function split() is deprecated, %s(74)
  101. array(1) {
  102. [0]=>
  103. string(5) "-10.5"
  104. }
  105. Arg value 101234567000
  106. Error: 8192 - Function split() is deprecated, %s(74)
  107. array(1) {
  108. [0]=>
  109. string(12) "101234567000"
  110. }
  111. Arg value 1.07654321E-9
  112. Error: 8192 - Function split() is deprecated, %s(74)
  113. array(2) {
  114. [0]=>
  115. string(10) "1.07654321"
  116. [1]=>
  117. string(2) "-9"
  118. }
  119. Arg value 0.5
  120. Error: 8192 - Function split() is deprecated, %s(74)
  121. array(1) {
  122. [0]=>
  123. string(3) "0.5"
  124. }
  125. Error: 8 - Array to string conversion, %ssplit_variation_002.php(%d)
  126. Arg value Array
  127. Error: 8192 - Function split() is deprecated, %s(74)
  128. Error: 2 - split() expects parameter 2 to be string, array given, %s(74)
  129. NULL
  130. Error: 8 - Array to string conversion, %ssplit_variation_002.php(%d)
  131. Arg value Array
  132. Error: 8192 - Function split() is deprecated, %s(74)
  133. Error: 2 - split() expects parameter 2 to be string, array given, %s(74)
  134. NULL
  135. Error: 8 - Array to string conversion, %ssplit_variation_002.php(%d)
  136. Arg value Array
  137. Error: 8192 - Function split() is deprecated, %s(74)
  138. Error: 2 - split() expects parameter 2 to be string, array given, %s(74)
  139. NULL
  140. Error: 8 - Array to string conversion, %ssplit_variation_002.php(%d)
  141. Arg value Array
  142. Error: 8192 - Function split() is deprecated, %s(74)
  143. Error: 2 - split() expects parameter 2 to be string, array given, %s(74)
  144. NULL
  145. Error: 8 - Array to string conversion, %ssplit_variation_002.php(%d)
  146. Arg value Array
  147. Error: 8192 - Function split() is deprecated, %s(74)
  148. Error: 2 - split() expects parameter 2 to be string, array given, %s(74)
  149. NULL
  150. Arg value
  151. Error: 8192 - Function split() is deprecated, %s(74)
  152. array(1) {
  153. [0]=>
  154. string(0) ""
  155. }
  156. Arg value
  157. Error: 8192 - Function split() is deprecated, %s(74)
  158. array(1) {
  159. [0]=>
  160. string(0) ""
  161. }
  162. Arg value 1
  163. Error: 8192 - Function split() is deprecated, %s(74)
  164. array(1) {
  165. [0]=>
  166. string(1) "1"
  167. }
  168. Arg value
  169. Error: 8192 - Function split() is deprecated, %s(74)
  170. array(1) {
  171. [0]=>
  172. string(0) ""
  173. }
  174. Arg value 1
  175. Error: 8192 - Function split() is deprecated, %s(74)
  176. array(1) {
  177. [0]=>
  178. string(1) "1"
  179. }
  180. Arg value
  181. Error: 8192 - Function split() is deprecated, %s(74)
  182. array(1) {
  183. [0]=>
  184. string(0) ""
  185. }
  186. Arg value
  187. Error: 8192 - Function split() is deprecated, %s(74)
  188. array(1) {
  189. [0]=>
  190. string(0) ""
  191. }
  192. Arg value
  193. Error: 8192 - Function split() is deprecated, %s(74)
  194. array(1) {
  195. [0]=>
  196. string(0) ""
  197. }
  198. Error: 4096 - Object of class stdClass could not be converted to string, %s(73)
  199. Arg value
  200. Error: 8192 - Function split() is deprecated, %s(74)
  201. Error: 2 - split() expects parameter 2 to be string, object given, %s(74)
  202. NULL
  203. Arg value
  204. Error: 8192 - Function split() is deprecated, %s(74)
  205. array(1) {
  206. [0]=>
  207. string(0) ""
  208. }
  209. Arg value
  210. Error: 8192 - Function split() is deprecated, %s(74)
  211. array(1) {
  212. [0]=>
  213. string(0) ""
  214. }
  215. Done