I would like to ask how we can put into an array a variable reference from the current object.
In my case i have an array used for curl post and some fields are static (grant type & scope) while others (id & secret) are dynamic.
More specifivally i want to put the id & the secret as shown below:
$headers = [
'client_id='=> $this->id,
'client_secret='=>$this->secret,
'grant_type='=>'client_credentials',
'scope='=>'public'
];
....
....
curl_setopt($s, CURLOPT_HTTPHEADER, $headers);
I am getting a "PHP Fatal error: Constant expression contains invalid operations in ..." for the second & third row.
idandsecretand are you sure they are set before calling thecurl_setopt($s, CURLOPT_HTTPHEADER, $headers);?$headersas an instance property?