1, "hage"=>2, "hige"=>3, ); print_r($arr); // Cast array to Object $obj = (Object)$arr; print_r($obj); // set member a new member $obj->message = "huga!"; print_r($obj); // Recursive assignment works. $obj->obj = $obj; print_r($obj); // array can be passed as well. $obj->arr = $arr; print_r($obj); // try to set a new method $obj->me = create_function( '', 'return $this->message;' ); print_r($obj); // This doesn't work. got error Call to undefined method stdClass::me(). // echo $obj->me()."\n"; // as it is seen, the new method is set as a String. echo gettype($obj->me)."\n"; function you() { return 'you! ' . $this->message; } // This doesn't work, because the function is executed without $this context // when it is assigned to the object. // $obj->you = you(); // this works, but as a string. $obj->you = you; print_r($obj); ?>