I'm wondering why I can't return result with getData() function? it is empty in browser (PHP 7.1), I'm trying to understand why.
I can print/echo it just fine o.O
class testObject
{
public $data;
function __construct($data)
{
$this->data = $data;
}
function showInfo()
{
print_r($this->data);
}
function getData()
{
$str = $this->data;
return $str;
}
}
$data = 'test';
$a = (new testObject($data))->getData();