1--TEST-- 2Test array_slice() - Third parameter (NULL vs 0) 3--FILE-- 4<?php 5 6var_dump(array_slice(range(1, 3), 0, NULL, 1)); 7var_dump(array_slice(range(1, 3), 0, 0, 1)); 8var_dump(array_slice(range(1, 3), 0, NULL)); 9var_dump(array_slice(range(1, 3), 0, 0)); 10 11var_dump(array_slice(range(1, 3), -1, 0)); 12var_dump(array_slice(range(1, 3), -1, 0, 1)); 13var_dump(array_slice(range(1, 3), -1, NULL)); 14var_dump(array_slice(range(1, 3), -1, NULL, 1)); 15 16 17$a = 'foo'; 18try { 19 var_dump(array_slice(range(1, 3), 0, $a)); 20} catch (TypeError $e) { 21 echo $e->getMessage(), "\n"; 22} 23try { 24 var_dump(array_slice(range(1, 3), 0, $a)); 25} catch (TypeError $e) { 26 echo $e->getMessage(), "\n"; 27} 28var_dump($a); 29 30?> 31--EXPECT-- 32array(3) { 33 [0]=> 34 int(1) 35 [1]=> 36 int(2) 37 [2]=> 38 int(3) 39} 40array(0) { 41} 42array(3) { 43 [0]=> 44 int(1) 45 [1]=> 46 int(2) 47 [2]=> 48 int(3) 49} 50array(0) { 51} 52array(0) { 53} 54array(0) { 55} 56array(1) { 57 [0]=> 58 int(3) 59} 60array(1) { 61 [2]=> 62 int(3) 63} 64array_slice(): Argument #3 ($length) must be of type ?int, string given 65array_slice(): Argument #3 ($length) must be of type ?int, string given 66string(3) "foo" 67