1

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

2
  • 3
    That's an object, not array. You can try $var->getShipmentNumber() to see if it works. Commented Oct 16, 2017 at 16:56
  • arrays !== objects Commented Oct 16, 2017 at 17:00

1 Answer 1

1

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

Demo

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.