How can definition a global variable for use in all function controller
class TestController extends Controller
{
    private $x;
    public function index()
    {
        $this->$x ='22';
    }            
    public function send_message()
    {
        echo $this->$x;
    }
}
                Write $this->x rather than $this->$x
class TestController extends Controller
{
    private $x;
    public function index()
    {
        $this->x ='22';
    }
    public function send_message()
    {
        echo $this->x;
    }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With