Reputation: 37
How i can read this array alone $var['shipment_number'] don't work?
EinName\EINUNTERNEHMEN\Response Object
(
[shipment_number:EinName\EINUNTERNEHMEN\Response:private] => 222253010000075775
[piece_number:EinName\EINUNTERNEHMEN\Response:private] =>
[label:EinName\EINUNTERNEHMEN\Response:private] => https://cig.Einurl.com
[returnLabel:EinName\EINUNTERNEHMEN\Response:private] =>
[exportDoc:EinName\EINUNTERNEHMEN\Response:private] =>
[labelType:EinName\EINUNTERNEHMEN\Response:private] => URL
[sequenceNumber:EinName\EINUNTERNEHMEN\Response:private] => 1
[statusCode:EinName\EINUNTERNEHMEN\Response:private] => 0
[statusText:EinName\EINUNTERNEHMEN\Response:private] => ok
[statusMessage:EinName\EINUNTERNEHMEN\Response:private] => Der Webservice wurde ohne Fehler ausgeführt.
[version:EinName\EINUNTERNEHMEN\Version:private] => 2.2
[mayor:EinName\EINUNTERNEHMEN\Version:private] => 2
[minor:EinName\EINUNTERNEHMEN\Version:private] => 2
)
Code link: https://pastebin.com/uDm6neRt
Upvotes: 1
Views: 37
Reputation: 9927
What you have there is an object, specifically an instance of EinName\EINUNTERNEHMEN\Response
. Further, the properties are private
, so you can only access them directly from inside the class.
See this example:
<?php
class Response {
private $var;
public function __construct($var) {
$this->var = $var;
}
public function getVar() {
return $this->var;
}
}
$res = new Response("test");
echo $res->getVar(); // test
echo $res->var; // fatal error, attempting to access a private property
So, if you don't have access to the class, to get the properties you need to use the getter, if it exists. Check the documentation of your Response
class, by convention it should look like this:
echo $var->getShipmentNumber();
Upvotes: 1