I can not use the "mysqli_connect" function. Can someone help me? You are returning the following error:
Fatal error: Constant expression contains invalid operations in /home/vagrant/Projects/products/app/Database/Connection.php on line 11
My code is this:
<?php
namespace App\Database\Connection;
class Connection
{
protected $host = '127.0.0.1';
protected $user = 'homestead';
protected $password = 'secret';
protected $database = 'products_crud';
protected $connection = mysqli_connect($this->host, $this->user, $this->password, $this->database);
}
The error happens in this line of code:
protected $connection = mysqli_connect($this->host, $this->user, $this->password, $this->database);