1
0
mirror of https://github.com/php/php-src.git synced 2026-03-25 08:42:29 +01:00
Files
archived-php-src/ext/standard/tests/strings/substr_replace_error.phpt
2020-06-24 13:13:44 +02:00

44 lines
1.6 KiB
PHP

--TEST--
Test substr_replace() function : error conditions
--FILE--
<?php
/*
* Testing substr_replace() for error conditions
*/
echo "*** Testing substr_replace() : error conditions ***\n";
$s1 = "Good morning";
echo "\n-- Testing substr_replace() function with start and length different types --\n";
var_dump(substr_replace($s1, "evening", array(5)));
var_dump(substr_replace($s1, "evening", 5, array(8)));
echo "\n-- Testing substr_replace() function with start and length with a different number of elements --\n";
var_dump(substr_replace($s1, "evening", array(5, 1), array(8)));
echo "\n-- Testing substr_replace() function with start and length as arrays but string not--\n";
var_dump(substr_replace($s1, "evening", array(5), array(8)));
?>
--EXPECTF--
*** Testing substr_replace() : error conditions ***
-- Testing substr_replace() function with start and length different types --
Warning: substr_replace(): 'start' and 'length' should be of same type - numerical or array in %s on line %d
string(12) "Good morning"
Warning: substr_replace(): 'start' and 'length' should be of same type - numerical or array in %s on line %d
string(12) "Good morning"
-- Testing substr_replace() function with start and length with a different number of elements --
Warning: substr_replace(): 'start' and 'length' should have the same number of elements in %s on line %d
string(12) "Good morning"
-- Testing substr_replace() function with start and length as arrays but string not--
Warning: substr_replace(): Functionality of 'start' and 'length' as arrays is not implemented in %s on line %d
string(12) "Good morning"