Record::get - jcobban/Genealogy GitHub Wiki
Up: class Record
This method obtains the current value of the field identified by the field name parameter. It has one parameter:
parameter | description |
---|---|
$field | The field name is case insensitive and may be a synonym defined by the derived class to facilitate readability. Late static binding is used so this method takes advantage of field name definitions in the derived class. The field name may also be a defined field name with 'checked' appended. The field name may also be a temporary field defined by assigning a value to it in the set method. This method creates a trace entry if the field name does not correspond to any field in the record and debugging is enabled. |
This method returns the current value of the field. If the field name is defined field name with 'checked' appended. the method returns the string 'checked="checked"' if the field is not zero. This method returns null if the field name does not correspond to any field in the record, and generates a warning message.
This method is called to implement $record[$field].
The warning message for an undefined reference is displayed to the client as, for example:
If $record->setGetModeHTML(true)
has been called the returned value is modified to be acceptable text for an HTML page. If the value of a field is a string which contains characters such as โ<', โ>', โโ', and โ&' which are meaningful to HTML those characters are replaced by HTML character entities by calling the PHP function htmlspecialchars(). Further if the value of the field is NULL or an empty string $record->get($field)
returns the character entity โ โ which is an HTML โnon-breaking spaceโ.
In the following example $address is an instance of class Address which is derived from class Record:
$template->set('ADDRESS1', $address->get('address1'));
$template->set('ADDRESS2', $address->get('address2'));
$template->set('CITY', $address->get('city'));
$template->set('STATE', $address->get('state'));
$template->set('ZIPCODE', $address->get('zipcode'));
$template->set('COUNTRY', $address->get('country'));
However in my opinion the following is more intuitively understandable:
$template->set('ADDRESS1', $address['address1']);
$template->set('ADDRESS2', $address['address2']);
$template->set('CITY', $address['city']);
$template->set('STATE', $address['state']);
$template->set('ZIPCODE', $address['zipcode']);
$template->set('COUNTRY', $address['country']);