Source Code:
(back to article)
<?php class bag { /* Member variables */ var $item1; var $item2; var $item3; function __construct($par1, $par2, $par3) { $this->item1 = $par1; $this->item2 = $par2; $this->item3 = $par3; } } // Create myBag object $myBag = new bag("Mobile", "Charger", "Cable"); echo "Before conversion : \n"; var_dump($myBag); // Coverting object to an array $myBagArray = (array) $myBag; echo "After conversion : \n"; var_dump($myBagArray); ?>
Result:
Report an issue