I am trying to get the the string “this info” inside this object lets call it $object, but data is protected, how can I access that pocket?
object(something)#29 (1) {
["_data":protected]=>
array(10) {
["Id"]=>
array(1) {
[0]=>
string(8) "this info"
}
["SyncToken"]=>
array(1) {
[0]=>
string(1) "0"
}
["MetaData"]=>
array(1) {
Obviously $object->_data gives me an errorCannot access protected property
If you – or the writer of the class – want other people to have access to a protected or private property, you need to provide that via a getter method in the class itself.
So in the class:
And in your program: