1
0
mirror of https://github.com/php/php-src.git synced 2026-04-14 19:41:05 +02:00
Files
archived-php-src/ext/standard/tests/strings/str_replace_basic.phpt
Nikita Popov a603c06e2e Support "string or array" in zpp
This is one of our more common argument unions. Usage is just
prototyped in a few places, certainly not a full conversion.

I'm removing the str_replace.phpt test, because aparently it was
split up into smaller tests at some point, but the original has
not been removed.

Closes GH-4970.
2019-12-05 12:25:57 +01:00

52 lines
1.1 KiB
PHP

--TEST--
Test str_replace() function basic function
--INI--
precision=14
--FILE--
<?php
/*
Prototype: mixed str_replace(mixed $search, mixed $replace,
mixed $subject [, int &$count]);
Description: Replace all occurrences of the search string with
the replacement string
*/
echo "\n*** Testing str_replace() on basic operations ***\n";
var_dump( str_replace("", "", "") );
var_dump( str_replace("e", "b", "test") );
var_dump( str_replace("", "", "", $count) );
var_dump( $count );
var_dump( str_replace("q", "q", "q", $count) );
var_dump( $count );
var_dump( str_replace("long string here", "", "", $count) );
var_dump( $count );
$fp = fopen( __FILE__, "r" );
$fp_copy = $fp;
try {
var_dump( str_replace($fp_copy, $fp_copy, $fp_copy, $fp_copy) );
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
var_dump( $fp_copy );
fclose($fp);
?>
--EXPECTF--
*** Testing str_replace() on basic operations ***
string(0) ""
string(4) "tbst"
string(0) ""
int(0)
string(1) "q"
int(1)
string(0) ""
int(0)
str_replace() expects parameter 3 to be string or array, resource given
resource(%d) of type (stream)