0

I want to return a value from the below scripts :

$wsdl_url = 'http://srv.test/erProject/services/services?wsdl';
    $client = new SOAPClient($wsdl_url);
    $params = array(
        'IPADDR' => "111.12.13.14",
    );
    $return = $client->getUserInfo($params);
    print_r($return);
    echo $return->getUserInfo->expiredate;

print_r work and return:

stdClass Object
(
    [return] => stdClass Object
        (
            [UserCredit] => stdClass Object
                (
                    [expiredate] => 23-02-2018
                )

            [resCode] => 1
        )

)

but echo will return :

PHP Notice: Undefined property: stdClass::$UserCredit

PHP Notice: Trying to get property of non-object

Thanks in advance

2
  • 1
    Your print_r() shows the expected structure. $return->return->UserCredit->expiredate. The property of the object stored in $return is return. Commented Oct 14, 2013 at 17:58
  • We don't now how getUserInfo($params) works, you can use this echo $return->return->UserCredit->expiredate; Commented Oct 14, 2013 at 17:59

2 Answers 2

3

If you want to echo a stdClass, you should use something like this:

echo $return->return->UserCredit->expiredate;
Sign up to request clarification or add additional context in comments.

Comments

1

It's a notice and it tells you that $client class has no property $UserCredit (type object).

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.