Hello everyone I am net developer.Now I am learning PHP. I am studying about the php objects and I try this code
<html>
<head>
</head>
<body>
<?php
$obj=(object)'ciao';
echo $obj->scalar;
?>
</body>
</html>
Here I want to know what is the scalar exactly? Why We are using it here?
Converting to object
If an object is converted to an object, it is not modified. If a value of any other type is converted to an object, a new instance of the stdClass built-in class is created. If the value was NULL, the new instance will be empty. Arrays convert to an object with properties named by keys, and corresponding values. For any other value, a member variable named scalar will contain the value.
<?php $obj = (object) 'ciao'; echo $obj->scalar; // outputs 'ciao' ?>
http://www.php.net/manual/en/language.types.object.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With