123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- --TEST--
- Test split() function : usage variations - unexpected type for arg 3
- --FILE--
- <?php
- /* Prototype : proto array split(string pattern, string string [, int limit])
- * Description: Split string into array by regular expression
- * Source code: ext/standard/reg.c
- * Alias to functions:
- */
- function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
- if (error_reporting() != 0) {
- // report non-silenced errors
- echo "Error: $err_no - $err_msg, $filename($linenum)\n";
- }
- }
- set_error_handler('test_error_handler');
- echo "*** Testing split() : usage variations ***\n";
- // Initialise function arguments not being substituted (if any)
- $pattern = b'[[:space:]]';
- $string = '1 2 3 4 5';
- //get an unset variable
- $unset_var = 10;
- unset ($unset_var);
- //array of values to iterate over
- $values = array(
- // float data
- 10.5,
- -10.5,
- 10.7654321E-10,
- .5,
- // array data
- array(),
- array(0),
- array(1),
- array(1, 2),
- array('color' => 'red', 'item' => 'pen'),
- // null data
- NULL,
- null,
- // boolean data
- true,
- false,
- TRUE,
- FALSE,
- // empty data
- "",
- '',
- // string data
- "string",
- 'string',
- // object data
- new stdclass(),
- // undefined data
- @$undefined_var,
- // unset data
- @$unset_var,
- );
- // loop through each element of the array for limit
- foreach($values as $value) {
- echo "\nArg value $value \n";
- var_dump( split($pattern, $string, $value) );
- };
- echo "Done";
- ?>
- --EXPECTF--
- *** Testing split() : usage variations ***
- Arg value 10.5
- Error: 8192 - Function split() is deprecated, %s(73)
- array(5) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "2"
- [2]=>
- string(1) "3"
- [3]=>
- string(1) "4"
- [4]=>
- string(1) "5"
- }
- Arg value -10.5
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Arg value 1.07654321E-9
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Arg value 0.5
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d)
- Arg value Array
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
- NULL
- Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d)
- Arg value Array
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
- NULL
- Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d)
- Arg value Array
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
- NULL
- Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d)
- Arg value Array
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
- NULL
- Error: 8 - Array to string conversion, %ssplit_variation_003.php(%d)
- Arg value Array
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, array given, %s(73)
- NULL
- Arg value
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Arg value
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Arg value 1
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Arg value
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Arg value 1
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Arg value
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Arg value
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, string given, %s(73)
- NULL
- Arg value
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, string given, %s(73)
- NULL
- Arg value string
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, string given, %s(73)
- NULL
- Arg value string
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, string given, %s(73)
- NULL
- Error: 4096 - Object of class stdClass could not be converted to string, %s(72)
- Arg value
- Error: 8192 - Function split() is deprecated, %s(73)
- Error: 2 - split() expects parameter 3 to be long, object given, %s(73)
- NULL
- Arg value
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Arg value
- Error: 8192 - Function split() is deprecated, %s(73)
- array(1) {
- [0]=>
- string(9) "1 2 3 4 5"
- }
- Done
|