[Solved] How can i access Return value throught the construct() from another function In PHP?


Constructors don’t return values and you can’t just echo an object, try this instead.

class some
{
    private $my_string;

    public function __construct()
    {
        $this->my_string = 'abc';
    }

    public function test() 
    {
        return $this->my_string;
    }
}

$some = new some;


echo $some->test();

solved How can i access Return value throught the construct() from another function In PHP?