JObject: Difference between revisions
From Joomla! Documentation
New page: <span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
{{Description:JObject}}
===Defined in===
libra... |
m preparing for archive only |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[JObject]] is a generic object class. It provides: | |||
* {{JVer|1.5}} a mechanism that allows __construct() in PHP4; | |||
* operations for creating and accessing arbitrary object variables; | |||
{{ | * an array for storing errors (ordinary strings or JException objects) and operations for working with them. | ||
===Defined in=== | ===Defined in=== | ||
Line 46: | Line 46: | ||
|} | |} | ||
===Importing=== | ===Importing=== | ||
<source lang="php">jimport( 'joomla.base.object' );</source> | <source lang="php">jimport( 'joomla.base.object' );</source> | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=JObject | category=JObject | ||
namespace=CodeExample | |||
category=ClassExample | category=ClassExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> |
Latest revision as of 01:55, 25 March 2017
JObject is a generic object class. It provides:
a mechanism that allows __construct() in PHP4;
- operations for creating and accessing arbitrary object variables;
- an array for storing errors (ordinary strings or JException objects) and operations for working with them.
Defined in
libraries/joomla/base/object.php
Methods
Method name | Description |
---|---|
__construct | Class constructor, overridden in descendant classes. |
__toString | Magic method to convert the object to a string gracefully. |
def | Sets a default value if not alreay assigned |
get | Returns a property of the object or the default value if the property is not set. |
getProperties | Returns an associative array of object properties. |
getError | Get the most recent error message. |
getErrors | Return all errors, if any. |
set | Modifies a property of the object, creating it if it does not already exist. |
setProperties | Set the object properties based on a named array/hash. |
setError | Add an error message. |
toString | Deprecated1.6 - Jun 24, 2009 __toString() |
Importing
jimport( 'joomla.base.object' );
would output
This example was originally provided by Artyom.