Typecast

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
abalfazl
Forum Commoner
Posts: 71
Joined: Mon Sep 05, 2005 10:05 pm

Typecast

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

typecasting an object does nothing to it.
Post Reply