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