Reputation: 150
So I do a print for my object: print_r ($objMailer);
And I get the following below:
mymailer Object
(
[_strRecipient:mymailer:private] =>
[_strBcc:mymailer:private] =>
[_strSubject:mymailer:private] =>
[_strEmail:mymailer:private] =>
[_arrData:mymailer:private] => Array
(
[full_name] => brian
[invitee_name] => test
[email] => [email protected]
[captcha] => kqd2q9
)
[_arrAttachments:mymailer:private] =>
[_blnCaptcha:mymailer:private] => 1
[_arrErrors:mymailer:private] => Array
(
)
)
I need to echo/print out just the 'full_name' field? How can I go about doing this?
Upvotes: 0
Views: 148
Reputation: 19979
The object you are referencing has an _arrData member variable which has private scope resolution, which means you cannot access it from outside the class. Chances are there is a public accessor which will allow you get the information you are after, but no way to tell unless you introspect the object itself.
I would suggest doing something like:
foreach (get_class_methods($mymailer) as $method) { echo 'M: ' . $method . '<br>'; } exit;
Then you can see the methods available to you, chances are there is a getData() method, with which you can do this:
$mailerData = $mymailer->getData();
var_dump($mailerData['full_name']);
There may even be a method to get the full name, something like this:
var_dump($mymailer->getFullname());
Upvotes: 0
Reputation: 197659
You can not trivially. As the print_r
output shows that is within a private member.
You can either provide it from within your (?) mymailer
object:
return $this->_arrData['full_name'];
or by using Reflection to make it accessible from the outside:
$refObj = new ReflectionObject($objMailer);
$refProp = $refObj->getProperty('_arrData');
$array = $refProp->getValue($objMailer);
echo $array['full_name'];
Upvotes: 3
Reputation: 11393
If you want to echo the value inside a method of mymailer
class, you may use:
echo $this->_arrData['full_name'];
Upvotes: 0