<html>
<body>
<pre>
$a = 5; // Integer
$b = 5.34; // Float
$c = "hello"; // String
$d = true; // Boolean
$e = NULL; // NULL
$a = (object) $a;
$b = (object) $b;
$c = (object) $c;
$d = (object) $d;
$e = (object) $e;
//To verify the type of any object in PHP, use the var_dump() function:
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($d);
var_dump($e);
</pre>
<p>When converting into objects, most data types converts into a object with one property, named "scalar", with the corresponding value.</p>
<p>NULL values converts to an empty object.</p>
</body>
</html>
object(stdClass)#1 (1) { ["scalar"]=> int(5) } object(stdClass)#2 (1) { ["scalar"]=> float(5.34) } object(stdClass)#3 (1) { ["scalar"]=> string(5) "hello" } object(stdClass)#4 (1) { ["scalar"]=> bool(true) } object(stdClass)#5 (0) { }
When converting into objects, most data types converts into a object with one property, named "scalar", with the corresponding value.
NULL values converts to an empty object.