user2381114
user2381114

Reputation: 471

Accessing a specific object by name/number?

I'm returning some data, and testing my return by using var_dump($this);. It returns the following:

object(ReportingService)#333 (2) {
  ["_arrErrors"]=>
  array(0) {
  }
  ["nameWS"]=>
  string(14) "reportingstuff"
}
{"arrMessages":[{"_strMessage":"Example.","_strType":"valid","_strModule":null}],"arrContent":{"isSuccess":"1","statistics":"<div id=\"entities\">

What I am trying to do is to access the nameWS property of the object, but cannot seem to do so.

What I've tried:

var_dump($this[0]->nameWS);

Upvotes: 0

Views: 64

Answers (2)

Borniet
Borniet

Reputation: 3546

You can access it via:

$this->nameWS;

The zero you were using is for the array in "_arrErrors", so you don't need that.

echo $this->nameWS;

will output:

reportingstuff

Upvotes: 0

hek2mgl
hek2mgl

Reputation: 157947

Use the following:

$this->nameWS;

You find more information in the manual Setting and Getting Object Properties

Upvotes: 2

Related Questions