I am new in flight php. I need some help, I create two classes client.class.php and deliveryServiceConnector.class.php and i have index.php. I want to use function from deliveryServiceConnector.class.php in client.class.php so I write this code:
public function __construct() { $this->connector = new deliveryServiceConnector(DOLIBARR_API_KEY,DOLIBARR_ROOT_URL,NuLL, $this->nodeName); $connector->testDisplayDev(); }
I got this error:
Undefined variable: connector (8) Any idea how can i fix my error, Thanks
Advertisement
Answer
You’re not using the same thing for the deliveryServiceConnector
. In the first line, inside the function, you use $this->connector
, but in the second line you use $connector
. Therefore it is undefined. Try to use the same thing twice. Either:
public function __construct() { $this->connector = new deliveryServiceConnector(DOLIBARR_API_KEY,DOLIBARR_ROOT_URL,NuLL, $this->nodeName); $this->connector->testDisplayDev(); }
or
public function __construct() { $connector = new deliveryServiceConnector(DOLIBARR_API_KEY,DOLIBARR_ROOT_URL,NuLL, $this->nodeName); $connector->testDisplayDev(); }