When i am trying to access object elements i get the following error.
PHP Fatal error: Uncaught Error: Cannot access protected property PHRETS\\Models\\Search\\Record::$fields in /var/www/html/PHRETS/retsphp.php:49
here is the object which is returned
object(PHRETS\Models\Search\Record)#36 (5) {
["resource":protected]=>
string(8) "Property"
["class":protected]=>
string(11) "Residential"
["fields":protected]=>
array(6) {
[0]=>
string(14) "ListAgentMlsId"
[1]=>
string(21) "ListAgentStateLicense"
[2]=>
string(18) "ListAgentFirstName"
[3]=>
string(19) "ListAgentKeyNumeric"
[4]=>
string(17) "ListAgentLastName"
[5]=>
string(19) "ListingContractDate"
}
["restricted_value":protected]=>
string(4) "****"
["values":protected]=>
array(6) {
["ListAgentMlsId"]=>
string(6) "pi5683"
["ListAgentStateLicense"]=>
string(8) "01968042"
["ListAgentFirstName"]=>
string(5) "Noemi"
["ListAgentKeyNumeric"]=>
string(9) "118522750"
["ListAgentLastName"]=>
string(6) "Castro"
["ListingContractDate"]=>
string(10) "2019-06-03"
}
}
Tried to access like
$record->fields[0].ListAgentMlsId
or
$record->resource
All create the same error Cannot access protected property
How can i access the values of this object ?
According to the definition of class PHRETS\\Models\\Search\\Record
, You should use method getFields()
to access protected property $fields
, If you want to access value for specific field, Just use it likes array, eg $record['ListAgentMlsId']
. Because Record class has implemented ArrayAccess
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.