1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 16:08:35 +02:00
Files
archived-php-src/ext/standard/tests/strings/stripos_error.phpt
T
2019-12-20 16:43:40 +01:00

37 lines
940 B
PHP

--TEST--
Test stripos() function : error conditions
--FILE--
<?php
/* Prototype : int stripos ( string $haystack, string $needle [, int $offset] );
* Description: Find position of first occurrence of a case-insensitive string
* Source code: ext/standard/string.c
*/
echo "*** Testing stripos() function: error conditions ***\n";
echo "\n-- Offset beyond the end of the string --\n";
try {
stripos("Hello World", "o", 12);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
echo "\n-- Offset before the start of the string --\n";
try {
stripos("Hello World", "o", -12);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
echo "*** Done ***";
?>
--EXPECT--
*** Testing stripos() function: error conditions ***
-- Offset beyond the end of the string --
Offset not contained in string
-- Offset before the start of the string --
Offset not contained in string
*** Done ***