CodeExample

4daab65e66059

From Joomla! Documentation

Revision as of 04:43, 17 April 2011 by Chris Davenport (talk | contribs) (CodeExample provided by Chris Davenport)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Example

$bunny = new JObject;
$bunny->set('animalType', 'hare');
$bunny->set('color', 'white');
$bunny->set('ears', 2);

$wolfy = new JObject;
$wolfy->setProperties(
                     array(
                           'animalType'=>'wolf',
                           'color'=>'grey',
                           'teeth'=>42,
                           'stomach'=>null
                           )
                     );


$wolfy->stomach = $bunny;

print_r($wolfy);

would output

JObject Object
(
    [_errors] => Array
        (
        )

    [animalType] => wolf
    [color] => grey
    [teeth] => 42
    [stomach] => JObject Object
        (
            [_errors] => Array
                (
                )

            [animalType] => hare
            [color] => white
            [ears] => 2
        )

)

This example was originally provided by Artyom.


Chris Davenport 04:43, 17 April 2011 (CDT) Edit comment