--TEST-- Test strstr() function --FILE-- "; var_dump( strstr($str, chr(128)) ); echo chr(255)." => "; var_dump( strstr($str, chr(255)) ); echo chr(256)." => "; var_dump( strstr($str, chr(256)) ); echo "\n*** Testing error conditions ***"; var_dump( strstr($string, "")); var_dump( strstr() ); // zero argument var_dump( strstr("") ); // null argument var_dump( strstr($string) ); // without "needle" var_dump( strstr("a", "b", "c") ); // args > expected var_dump( strstr(NULL, "") ); echo "\nDone"; fclose($resource1); closedir($resource2); ?> --EXPECTF-- *** Testing basic functionality of strstr() *** string(11) "test string" string(6) "string" string(6) "string" string(8) "t string" string(1) "g" string(32) "7272696018bdeb2c9a3f8d01fc2a9273" bool(false) bool(false) bool(false) bool(false) bool(false) *** Testing strstr() with various needles *** -- Iteration 0 -- string(86) "Hello world,012033 -3.3445 NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 1 -- bool(false) -- Iteration 2 -- string(40) " abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 3 -- string(40) " abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 4 -- string(28) "0 octal abcd$:Hello world" -- Iteration 5 -- string(38) "abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 6 -- string(32) "xyz 0 octal abcd$:Hello world" -- Iteration 7 -- string(25) "octal abcd$:Hello world" -- Iteration 8 -- string(67) "-3.3445 NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 9 -- Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d bool(false) -- Iteration 10 -- string(67) "-3.3445 NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 11 -- Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d bool(false) -- Iteration 12 -- Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d string(40) " abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 13 -- string(55) "NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 14 -- string(74) "012033 -3.3445 NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 15 -- Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d string(40) " abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 16 -- Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d bool(false) -- Iteration 17 -- string(50) "TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 18 -- string(73) "12033 -3.3445 NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 19 -- Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d bool(false) -- Iteration 20 -- Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d string(40) " abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 21 -- string(45) "FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 22 -- string(81) " world,012033 -3.3445 NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 23 -- string(60) " NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 24 -- string(37) "bcd\xxyz 0 octal abcd$:Hello world" -- Iteration 25 -- bool(false) -- Iteration 26 -- string(20) " abcd$:Hello world" -- Iteration 27 -- string(73) "12033 -3.3445 NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" -- Iteration 28 -- bool(false) -- Iteration 29 -- string(86) "Hello world,012033 -3.3445 NULL TRUE FALSE abcd\xxyz 0 octal abcd$:Hello world" *** Testing Miscelleneous input data *** -- Passing objects as string and needle -- string(5) "world" -- passing an array as string and needle -- Warning: strstr() expects parameter 1 to be string, array given in %s on line %d NULL string(27) "?world,!$%**()%**[][[[&@#~!" string(20) "!$%**()%**[][[[&@#~!" -- passing Resources as string and needle -- Warning: strstr() expects parameter 1 to be string, resource given in %s on line %d NULL Warning: strstr() expects parameter 1 to be string, resource given in %s on line %d NULL -- Posiibilities with null -- Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d bool(false) Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d bool(false) Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d bool(false) string(1) "0" -- A longer and heredoc string -- string(729) "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789" string(702) "123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789" -- A heredoc null string -- bool(false) Deprecated: strstr(): Non-string needles will be interpreted as strings in %s on line %d bool(false) bool(false) -- simple and complex syntax strings -- string(5) "world" string(7) "world'S" Notice: Undefined variable: needleS in %s on line %d Warning: strstr(): Empty needle in %s on line %d bool(false) string(6) "worldS" string(6) "worldS" -- complex strings containing other than 7-bit chars -- - Positions of some chars in the string '' are as follows - => string(6) "" => string(1) "" => string(7) "" *** Testing error conditions *** Warning: strstr(): Empty needle in %s on line %d bool(false) Warning: strstr() expects at least 2 parameters, 0 given in %s on line %d NULL Warning: strstr() expects at least 2 parameters, 1 given in %s on line %d NULL Warning: strstr() expects at least 2 parameters, 1 given in %s on line %d NULL bool(false) Warning: strstr(): Empty needle in %s on line %d bool(false) Done