| API | Package | Subpackage | Class | Method | Reference | Last reviewed | Doc status |
|---|---|---|---|---|---|---|---|
Home |
Joomla.Framework |
Base |
JObject |
getProperties |
getProperties() |
Never | Work in Progress |
This function returns an array of property names.
array getProperties ($public = true)
| $public | boolean | whether to include private properties in the result |
See also: * JObject::set * JObject::get * JObject::setProperties
The method is designed to only return the public properties of an object. Since the concept of public, protected, and private properties is only available as of PHP5, the underscore character is used as a prefix to mark properties visually as private. This is common practice in PHP land and not specific to Joomla!
Example 1
$myobj = new JObject(); // set some properties $myobj->set('name', 'Anonymous'); $myobj->set('version', '1.0'); $myobj->set('_secret', '4711'); print_r( $myobj->getProperties() );
will produce:
Result 1
Array ( [name] => Anonymous [version] => 1.0 )
In order to retrieve all properties from an object, you must provide false for the ‘$public’ argument.
Example 2
print_r( $myobj->getProperties(false) );
will produce:
Result 1
Array ( [_errors] => Array ( ) [name] => Anonymous [version] => 1.0 [_secret] => 4711 )
The ‘_errors’ property shown in this output is declared in the JObject class.