Page 1 of 1

Typecast

Posted: Tue Sep 27, 2005 11:02 am
by abalfazl
Hello firends

From:http://nl2.php.net/manual/en/language.t ... ggling.php
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. For any other value, a member variable named scalar will contain the value.


<?php
$obj = (object) 'ciao';
echo $obj->scalar; // outputs 'ciao'
?>


That description and that example is not clearly at all,May you give another example ?Suppose we have created and a claas and have variable.How do we typecast?

Good Luck

Posted: Tue Sep 27, 2005 11:12 am
by feyd
typecasting an object does nothing to it.