-- Kexiao Liao <[EMAIL PROTECTED]> wrote
(on Wednesday, 26 September 2007, 05:58 AM -0700):
> The stdClass has been used in ZF in many demo examples. Does this class have
> toArray() method? Does it belong to ZF only?
stdClass is a PHP internal class, and can be used when you want an
object but do not want to define a class. Such a class will have no
methods other than the internal magic methods, but can have any number
of public properties; thus, no toArray() method. However, if you want to
cast it to an array, you can, and it will serialize any public
properties:
$o = new stdClass;
$o->foo = 'bar';
$o->bar = 'baz';
$array = (array) $o;
// $array now equals array('foo' => 'bar', 'bar' => 'baz')
toArray() is not a general method available to all classes; we use it in
ZF when an object may be serialized to array easily, and we standardized
on that name to make it predictable.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/