How do I echo the value from the object? In the following example I expect 1105 service number to be printed after "case".
$vbk->set('service_no','1105');
echo "case".$vbk->service_no;
I need to use object for this purpose.
How do I echo the value from the object? In the following example I expect 1105 service number to be printed after "case".
$vbk->set('service_no','1105');
echo "case".$vbk->service_no;
I need to use object for this purpose.
Implement a __get function which will handle that logic. POC:
<?php
class service
{
private $properties = array();
public function set($key, $value)
{
$this->properties[$key] = $value;
}
public function __get($key)
{
if(isset($this->properties[$key]))
return $this->properties[$key];
return null;
}
}
$service = new service;
$service->set('service_no','1105');
// case1105
echo "case".$service->service_no;