--TEST-- Test strrchr() function : usage variations - unexpected inputs for needle --FILE-- 'red', 'item' => 'pen'), // boolean values true, false, TRUE, FALSE, // null values NULL, null, // objects new sample(), // empty string "", '', // resource $file_handle, // undefined variable @$undefined_var, // unset variable @$unset_var ); // loop through each element of the array and check the working of strrchr() $count = 1; for($index = 0; $index < count($haystacks); $index++) { echo "-- Iteration $count --\n"; try { var_dump( strrchr($haystacks[$index], $needles[$index]) ); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } $count ++; } fclose($file_handle); //closing the file handle echo "*** Done ***"; ?> --EXPECT-- *** Testing strrchr() function with unexpected inputs for needle *** -- Iteration 1 -- string(1) "0" -- Iteration 2 -- string(1) "1" -- Iteration 3 -- bool(false) -- Iteration 4 -- string(2) "-2" -- Iteration 5 -- string(4) "10.5" -- Iteration 6 -- string(5) "-10.5" -- Iteration 7 -- string(2) "10" -- Iteration 8 -- string(2) "10" -- Iteration 9 -- bool(false) -- Iteration 10 -- strrchr(): Argument #2 ($needle) must be of type string, array given -- Iteration 11 -- strrchr(): Argument #2 ($needle) must be of type string, array given -- Iteration 12 -- strrchr(): Argument #2 ($needle) must be of type string, array given -- Iteration 13 -- strrchr(): Argument #2 ($needle) must be of type string, array given -- Iteration 14 -- strrchr(): Argument #2 ($needle) must be of type string, array given -- Iteration 15 -- bool(false) -- Iteration 16 -- bool(false) -- Iteration 17 -- bool(false) -- Iteration 18 -- bool(false) -- Iteration 19 -- bool(false) -- Iteration 20 -- bool(false) -- Iteration 21 -- string(6) "object" -- Iteration 22 -- bool(false) -- Iteration 23 -- bool(false) -- Iteration 24 -- strrchr(): Argument #2 ($needle) must be of type string, resource given -- Iteration 25 -- bool(false) -- Iteration 26 -- bool(false) *** Done ***