php-src/Zend/tests/cast_to_string.phpt
2020-02-03 22:52:20 +01:00

58 lines
784 B
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--TEST--
casting different variables to string
--FILE--
<?php
$r = fopen(__FILE__, "r");
class test {
function __toString() {
return "10";
}
}
$o = new test;
$vars = array(
"string",
"8754456",
"",
"\0",
9876545,
0.10,
array(),
array(1,2,3),
false,
true,
NULL,
$r,
$o
);
foreach ($vars as $var) {
$tmp = (string)$var;
var_dump($tmp);
}
echo "Done\n";
?>
--EXPECTF--
string(6) "string"
string(7) "8754456"
string(0) ""
string(1) ""
string(7) "9876545"
string(3) "0.1"
Warning: Array to string conversion in %s on line %d
string(5) "Array"
Warning: Array to string conversion in %s on line %d
string(5) "Array"
string(0) ""
string(1) "1"
string(0) ""
string(%d) "Resource id #%d"
string(2) "10"
Done