I'm new to PHP. I'm trying use the new(ish) format square brackets for an array assigned to variables.
This is it in the old format:
$header = array('Accept: application/json','Content-Type: application/json','Authorization: Bearer ACCESSTOKEN','x-api-key: APIKEY','x-proxy-global-company-id: COMPANYID');
This is what the tutorial talks about for the style of new brakets:
$array = [
"foo" => "bar",
"bar" => "foo",
];
?>
The items I want is like the following in my header:
Accept: application/json
Content-Type: application/json
Authorization: Bearer ACCESSTOKEN
x-api-key: APIKEY
x-proxy-global-company-id: COMPANYID
Therefore I thought my header variable should be assigned an array like this:
$header = [
"Accept: application/json",
"Content-Type: application/json",
"Authorization: Bearer ACCESSTOKEN",
"x-api-key: APIKEY",
"x-proxy-global-company-id: COMPANYID",
];
This doesn't validate so I know I'm wrong. It says unexpected T string on line 5. Can anyone give me a tip on where I have gone wrong please?
Your header should be like below:
$header = [
"Accept" => "application/json",
"Content-Type" => "application/json",
"Authorization" => "Bearer ACCESSTOKEN",
"x-api-key" => "APIKEY",
"x-proxy-global-company-id" => "COMPANYID",
];