iconv.internal_charset=ISO-8859-1
--FILE--
<?php
-function my_error_handler($errno, $errmsg, $filename, $linenum)
-{
- echo "$errno: $errmsg\n";
-}
-set_error_handler('my_error_handler');
function foo($haystk, $needle, $offset, $to_charset = false, $from_charset = false)
{
if ($from_charset !== false) {
$haystk = iconv($from_charset, $to_charset, $haystk);
}
- var_dump(strpos($haystk, $needle, $offset));
+ try {
+ var_dump(strpos($haystk, $needle, $offset));
+ } catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
if ($to_charset !== false) {
var_dump(iconv_strpos($haystk, $needle, $offset, $to_charset));
} else {
bool(false)
int(5)
int(5)
-2: %s
-bool(false)
+Offset not contained in string
bool(false)
int(7)
int(7)
echo "mb_strrpos:\n";
var_dump(mb_strrpos('This is na English ta', 'a', $i));
echo "strrpos:\n";
- var_dump(strrpos('This is na English ta', 'a', $i));
+ try {
+ var_dump(strrpos('This is na English ta', 'a', $i));
+ } catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
}
?>
--EXPECTF--
Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
strrpos:
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
-- Offset is -24 --
Multibyte String:
Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
strrpos:
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
-- Offset is -13 --
Multibyte String:
echo "\n------- $func -----------\n\n";
foreach(array(0, 3, 6, 9, 11, 12, -1, -3, -6, -20) as $offset) {
echo "> Offset: $offset\n";
- var_dump($func($haystack,$needle,$offset));
+ try {
+ var_dump($func($haystack,$needle,$offset));
+ } catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
}
}
> Offset: 11
bool(false)
> Offset: 12
-
-Warning: strpos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
> Offset: -1
bool(false)
> Offset: -3
> Offset: -6
int(8)
> Offset: -20
-
-Warning: strpos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
------- mb_strpos -----------
> Offset: 11
bool(false)
> Offset: 12
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
> Offset: -1
bool(false)
> Offset: -3
> Offset: -6
int(8)
> Offset: -20
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
------- mb_stripos -----------
> Offset: 11
bool(false)
> Offset: 12
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
> Offset: -1
int(8)
> Offset: -3
> Offset: -6
int(4)
> Offset: -20
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
------- mb_strrpos -----------
> Offset: 11
bool(false)
> Offset: 12
-
-Warning: strripos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
> Offset: -1
int(8)
> Offset: -3
> Offset: -6
int(4)
> Offset: -20
-
-Warning: strripos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
------- mb_strripos -----------
offset += (zend_long)ZSTR_LEN(haystack);
}
if (offset < 0 || (size_t)offset > ZSTR_LEN(haystack)) {
- php_error_docref(NULL, E_WARNING, "Offset not contained in string");
- RETURN_FALSE;
+ zend_value_error("Offset not contained in string");
+ return;
}
found = (char*)php_memnstr(ZSTR_VAL(haystack) + offset,
offset += (zend_long)ZSTR_LEN(haystack);
}
if (offset < 0 || (size_t)offset > ZSTR_LEN(haystack)) {
- php_error_docref(NULL, E_WARNING, "Offset not contained in string");
- RETURN_FALSE;
+ zend_value_error("Offset not contained in string");
+ return;
}
if (ZSTR_LEN(needle) > ZSTR_LEN(haystack)) {
if (offset >= 0) {
if ((size_t)offset > ZSTR_LEN(haystack)) {
- php_error_docref(NULL, E_WARNING, "Offset not contained in string");
- RETURN_FALSE;
+ zend_value_error("Offset not contained in string");
+ return;
}
p = ZSTR_VAL(haystack) + (size_t)offset;
e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack);
} else {
- if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
- php_error_docref(NULL, E_WARNING, "Offset not contained in string");
- RETURN_FALSE;
+ if (offset < -ZEND_LONG_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
+ zend_value_error("Offset not contained in string");
+ return;
}
p = ZSTR_VAL(haystack);
char lowered;
if (offset >= 0) {
if ((size_t)offset > ZSTR_LEN(haystack)) {
- php_error_docref(NULL, E_WARNING, "Offset not contained in string");
- RETURN_FALSE;
+ zend_value_error("Offset not contained in string");
+ return;
}
p = ZSTR_VAL(haystack) + (size_t)offset;
e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack) - 1;
} else {
p = ZSTR_VAL(haystack);
- if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
- php_error_docref(NULL, E_WARNING, "Offset not contained in string");
- RETURN_FALSE;
+ if (offset < -ZEND_LONG_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
+ zend_value_error("Offset not contained in string");
+ return;
}
e = ZSTR_VAL(haystack) + (ZSTR_LEN(haystack) + (size_t)offset);
}
if (offset >= 0) {
if ((size_t)offset > ZSTR_LEN(haystack)) {
zend_string_release_ex(haystack_dup, 0);
- php_error_docref(NULL, E_WARNING, "Offset not contained in string");
- RETURN_FALSE;
+ zend_value_error("Offset not contained in string");
+ return;
}
p = ZSTR_VAL(haystack_dup) + offset;
e = ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack);
} else {
- if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
+ if (offset < -ZEND_LONG_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
zend_string_release_ex(haystack_dup, 0);
- php_error_docref(NULL, E_WARNING, "Offset not contained in string");
- RETURN_FALSE;
+ zend_value_error("Offset not contained in string");
+ return;
}
p = ZSTR_VAL(haystack_dup);
offset += (zend_long)haystack_len;
}
if ((offset < 0) || ((size_t)offset > haystack_len)) {
- php_error_docref(NULL, E_WARNING, "Offset not contained in string");
- RETURN_FALSE;
+ zend_value_error("Offset not contained in string");
+ return;
}
p += offset;
var_dump(strspn("abcde", "abc", $v, $v));
var_dump(strcspn("abcde", "abc", $v, $v));
-var_dump(substr_count("abcde", "abc", $v, $v));
+try {
+ var_dump(substr_count("abcde", "abc", $v, $v));
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
var_dump(substr_compare("abcde", "abc", $v, $v));
-var_dump(stripos("abcde", "abc", $v));
-var_dump(substr_count("abcde", "abc", $v, 1));
+try {
+ stripos("abcde", "abc", $v);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ substr_count("abcde", "abc", $v, 1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
var_dump(substr_count("abcde", "abc", 1, $v));
-var_dump(strpos("abcde", "abc", $v));
-var_dump(stripos("abcde", "abc", $v));
-var_dump(strrpos("abcde", "abc", $v));
-var_dump(strripos("abcde", "abc", $v));
+
+try {
+ strpos("abcde", "abc", $v);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ stripos("abcde", "abc", $v);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ strrpos("abcde", "abc", $v);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+try {
+ strripos("abcde", "abc", $v);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
var_dump(strncmp("abcde", "abc", $v));
var_dump(chunk_split("abcde", $v, "abc"));
var_dump(substr("abcde", $v, $v));
string(6) "abcdex"
bool(false)
bool(false)
-
-Warning: substr_count(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d
bool(false)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
-
-Warning: substr_count(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
+Offset not contained in string
Warning: substr_count(): Invalid length value in %s on line %d
bool(false)
-
-Warning: strpos(): Offset not contained in string in %s on line %d
-bool(false)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
-
-Warning: strripos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
+Offset not contained in string
+Offset not contained in string
+Offset not contained in string
int(2)
string(8) "abcdeabc"
bool(false)
echo "*** Testing stripos() function: error conditions ***\n";
-echo "\n-- Offset beyond the end of the string --";
-var_dump( stripos("Hello World", "o", 12) );
+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 --";
-var_dump( stripos("Hello World", "o", -12) );
+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 ***";
?>
---EXPECTF--
+--EXPECT--
*** Testing stripos() function: error conditions ***
-- Offset beyond the end of the string --
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
-- Offset before the start of the string --
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
*** Done ***
$haystack = $values[$index];
try {
var_dump( stripos($values[$index], $values[$index]) );
- } catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ } catch (Error $e) {
+ echo get_class($e) . ": " . $e->getMessage(), "\n";
}
try {
var_dump( stripos($values[$index], $values[$index], 1) );
- } catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ } catch (Error $e) {
+ echo get_class($e) . ": " . $e->getMessage(), "\n";
}
$counter ++;
}
int(0)
bool(false)
-- Iteration 10 --
-stripos() expects parameter 1 to be string, array given
-stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
-- Iteration 11 --
-stripos() expects parameter 1 to be string, array given
-stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
-- Iteration 12 --
-stripos() expects parameter 1 to be string, array given
-stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
-- Iteration 13 --
-stripos() expects parameter 1 to be string, array given
-stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
-- Iteration 14 --
-stripos() expects parameter 1 to be string, array given
-stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
+TypeError: stripos() expects parameter 1 to be string, array given
-- Iteration 15 --
int(0)
bool(false)
-- Iteration 16 --
int(0)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 17 --
int(0)
bool(false)
-- Iteration 18 --
int(0)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 19 --
int(0)
bool(false)
-- Iteration 20 --
int(0)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 21 --
int(0)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 22 --
int(0)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 23 --
int(0)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 24 --
-stripos() expects parameter 1 to be string, resource given
-stripos() expects parameter 1 to be string, resource given
+TypeError: stripos() expects parameter 1 to be string, resource given
+TypeError: stripos() expects parameter 1 to be string, resource given
-- Iteration 25 --
int(0)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 26 --
int(0)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
*** Done ***
$empty_string = <<<EOD
EOD;
var_dump( stripos($empty_string, "") );
-var_dump( stripos($empty_string, "", 1) );
+
+try {
+ stripos($empty_string, "", 1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
var_dump( stripos($empty_string, FALSE) );
var_dump( stripos($empty_string, NULL) );
echo "*** Done ***";
?>
---EXPECTF--
+--EXPECT--
*** Testing stripos() function: with heredoc strings ***
-- With empty heredoc string --
int(0)
-
-Warning: stripos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
int(0)
int(0)
*** Done ***
echo $e->getMessage(), "\n";
}
-var_dump(strripos(1024, 1024, -PHP_INT_MAX));
-var_dump(strripos(1024, "te", -PHP_INT_MAX));
-var_dump(strripos(1024, 1024, -PHP_INT_MAX-1));
-var_dump(strripos(1024, "te", -PHP_INT_MAX-1));
-
-echo "Done\n";
-?>
---EXPECTF--
-strripos() expects parameter 3 to be int, float given
+try {
+ strripos(1024, 1024, -PHP_INT_MAX);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: strripos(): Offset not contained in string in %s on line %d
-bool(false)
+try {
+ strripos(1024, "te", -PHP_INT_MAX);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: strripos(): Offset not contained in string in %s on line %d
-bool(false)
+try {
+ strripos(1024, 1024, -PHP_INT_MAX-1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: strripos(): Offset not contained in string in %s on line %d
-bool(false)
+try {
+ strripos(1024, "te", -PHP_INT_MAX-1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: strripos(): Offset not contained in string in %s on line %d
-bool(false)
+echo "Done\n";
+?>
+--EXPECT--
+strripos() expects parameter 3 to be int, float given
+Offset not contained in string
+Offset not contained in string
+Offset not contained in string
+Offset not contained in string
Done
var_dump(strrpos("haystack", "ka", -1));
var_dump(strrpos("haystack", 'a', -3));
var_dump(strrpos("haystack", 'a', -4));
- var_dump(@strrpos("haystack", 'h', -9));
-
+ try {
+ strrpos("haystack", 'h', -9);
+ } catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
var_dump(strripos("HAYSTHACk", 'ha', -9));
var_dump(strripos("HAYSTACK", 'h', -8));
var_dump(strripos("HAYSTACK", 'k', -1));
var_dump(strripos("HAYSTACK", "ka", -1));
var_dump(strripos("HAYSTACK", 'a', -3));
var_dump(strripos("HAYSTACK", 'a', -4));
- var_dump(@strripos("HAYSTACK", 'h', -9));
+ try {
+ strripos("HAYSTACK", 'h', -9);
+ } catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
?>
--EXPECT--
int(0)
bool(false)
int(5)
int(1)
-bool(false)
+Offset not contained in string
int(0)
int(0)
int(7)
bool(false)
int(5)
int(1)
-bool(false)
+Offset not contained in string
echo $e->getMessage(), "\n";
}
-var_dump(strrpos(1024, 1024, -PHP_INT_MAX));
-var_dump(strrpos(1024, "te", -PHP_INT_MAX));
-var_dump(strrpos(1024, 1024, -PHP_INT_MAX-1));
-var_dump(strrpos(1024, "te", -PHP_INT_MAX-1));
-
-echo "Done\n";
-?>
---EXPECTF--
-strrpos() expects parameter 3 to be int, float given
+try {
+ strrpos(1024, 1024, -PHP_INT_MAX);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+try {
+ strrpos(1024, "te", -PHP_INT_MAX);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+try {
+ strrpos(1024, 1024, -PHP_INT_MAX-1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+try {
+ strrpos(1024, "te", -PHP_INT_MAX-1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+echo "Done\n";
+?>
+--EXPECT--
+strrpos() expects parameter 3 to be int, float given
+Offset not contained in string
+Offset not contained in string
+Offset not contained in string
+Offset not contained in string
Done
$haystack = $values[$index];
try {
var_dump( strrpos($values[$index], $values[$index]) );
- } catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ } catch (Error $e) {
+ echo get_class($e) . ": " . $e->getMessage(), "\n";
}
+
try {
var_dump( strrpos($values[$index], $values[$index], 1) );
- } catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ } catch (Error $e) {
+ echo get_class($e) . ": " . $e->getMessage(), "\n";
}
$counter ++;
}
int(0)
bool(false)
-- Iteration 10 --
-strrpos() expects parameter 1 to be string, array given
-strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
-- Iteration 11 --
-strrpos() expects parameter 1 to be string, array given
-strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
-- Iteration 12 --
-strrpos() expects parameter 1 to be string, array given
-strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
-- Iteration 13 --
-strrpos() expects parameter 1 to be string, array given
-strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
-- Iteration 14 --
-strrpos() expects parameter 1 to be string, array given
-strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
+TypeError: strrpos() expects parameter 1 to be string, array given
-- Iteration 15 --
int(0)
bool(false)
-- Iteration 16 --
int(0)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 17 --
int(0)
bool(false)
-- Iteration 18 --
int(0)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 19 --
int(0)
bool(false)
-- Iteration 20 --
int(0)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 21 --
int(0)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 22 --
int(0)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 23 --
int(0)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 24 --
-strrpos() expects parameter 1 to be string, resource given
-strrpos() expects parameter 1 to be string, resource given
+TypeError: strrpos() expects parameter 1 to be string, resource given
+TypeError: strrpos() expects parameter 1 to be string, resource given
-- Iteration 25 --
int(0)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
-- Iteration 26 --
int(0)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+ValueError: Offset not contained in string
*** Done ***
$empty_string = <<<EOD
EOD;
var_dump( strrpos($empty_string, "") );
-var_dump( strrpos($empty_string, "", 1) );
+try {
+ strrpos($empty_string, "", 1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
var_dump( strrpos($empty_string, FALSE) );
var_dump( strrpos($empty_string, NULL) );
echo "*** Done ***";
?>
---EXPECTF--
+--EXPECT--
*** Testing strrpos() function: with heredoc strings ***
-- With empty heredoc string --
int(0)
-
-Warning: strrpos(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
int(0)
int(0)
*** Done ***
$str = 'abcdefghik';
/* offset before start */
-var_dump(substr_count($str, "t", -20));
+try {
+ substr_count($str, "t", -20);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
/* offset > size of the string */
-var_dump(substr_count($str, "t", 25));
+try {
+ substr_count($str, "t", 25);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
/* Using offset and length to go beyond the size of the string:
Warning message expected, as length+offset > length of string */
?>
--EXPECTF--
*** Testing error conditions ***
-
-Warning: substr_count(): Offset not contained in string in %s on line %d
-bool(false)
-
-Warning: substr_count(): Offset not contained in string in %s on line %d
-bool(false)
+Offset not contained in string
+Offset not contained in string
Warning: substr_count(): Invalid length value in %s on line %d
bool(false)