2007-04-28 05:33:02 +08:00
|
|
|
|
--TEST--
|
2018-10-15 00:03:31 +08:00
|
|
|
|
casting different variables to object
|
2007-04-28 05:33:02 +08:00
|
|
|
|
--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 = (object)$var;
|
|
|
|
|
var_dump($tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "Done\n";
|
|
|
|
|
?>
|
2018-10-15 00:03:31 +08:00
|
|
|
|
--EXPECTF--
|
2007-04-28 05:33:02 +08:00
|
|
|
|
object(stdClass)#%d (1) {
|
|
|
|
|
["scalar"]=>
|
|
|
|
|
string(6) "string"
|
|
|
|
|
}
|
|
|
|
|
object(stdClass)#%d (1) {
|
|
|
|
|
["scalar"]=>
|
|
|
|
|
string(7) "8754456"
|
|
|
|
|
}
|
|
|
|
|
object(stdClass)#%d (1) {
|
|
|
|
|
["scalar"]=>
|
|
|
|
|
string(0) ""
|
|
|
|
|
}
|
|
|
|
|
object(stdClass)#%d (1) {
|
|
|
|
|
["scalar"]=>
|
|
|
|
|
string(1) " |