rtrim_variation2.phpt [plain text]
--TEST--
Test rtrim() function : usage variations - test values for $charlist argument
--FILE--
<?php
echo "*** Testing rtrim() function: with unexpected inputs for 'charlist' argument ***\n";
$unset_var = ' string_val ';
unset($unset_var);
class sample {
public function __toString() {
return " sample object ";
}
}
$file_handle = fopen(__FILE__, "r");
$inputs = array (
0,
1,
255,
256,
2147483647,
-2147483648,
10.5,
-20.5,
10.1234567e10,
array(),
array(0),
array(1, 2),
true,
false,
TRUE,
FALSE,
NULL,
null,
new sample(),
$file_handle,
@$undefined_var,
@$unset_var
);
$count = 1;
foreach($inputs as $charlist) {
echo "-- Iteration $count --\n";
var_dump( rtrim("!---Hello World---!", $charlist) );
$count ++;
}
fclose($file_handle);
?>
===DONE===
--EXPECTF--
*** Testing rtrim() function: with unexpected inputs for 'charlist' argument ***
-- Iteration 1 --
string(19) "!---Hello World---!"
-- Iteration 2 --
string(19) "!---Hello World---!"
-- Iteration 3 --
string(19) "!---Hello World---!"
-- Iteration 4 --
string(19) "!---Hello World---!"
-- Iteration 5 --
string(19) "!---Hello World---!"
-- Iteration 6 --
string(19) "!---Hello World---!"
-- Iteration 7 --
string(19) "!---Hello World---!"
-- Iteration 8 --
string(19) "!---Hello World---!"
-- Iteration 9 --
string(19) "!---Hello World---!"
-- Iteration 10 --
Warning: rtrim() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 11 --
Warning: rtrim() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 12 --
Warning: rtrim() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 13 --
string(19) "!---Hello World---!"
-- Iteration 14 --
string(19) "!---Hello World---!"
-- Iteration 15 --
string(19) "!---Hello World---!"
-- Iteration 16 --
string(19) "!---Hello World---!"
-- Iteration 17 --
string(19) "!---Hello World---!"
-- Iteration 18 --
string(19) "!---Hello World---!"
-- Iteration 19 --
string(19) "!---Hello World---!"
-- Iteration 20 --
Warning: rtrim() expects parameter 2 to be string, resource given in %s on line %d
NULL
-- Iteration 21 --
string(19) "!---Hello World---!"
-- Iteration 22 --
string(19) "!---Hello World---!"
===DONE===