Error when setting a constant

Asked

Viewed 51 times

1

I’m getting the following error in my code, and I’m not getting the reason why.

Got error 'PHP message: PHP Warning: Constants may only evaluate to scalar values in config.php on line 85

On the lines 81 to 85 I have the following:

define("DATA_CONFIG",[
   "master_id" => $dados_config->sistema_master_id,
   "sis_url" => $dados_config->sistema_url,
   "api_key" => base64_decode($dados_config->sistema_key)
]);

In the 85 I have the closing, but in the 84 I have the following line, there is some problem to use the base64_decode in a constant? Or making this conversion where I am doing may cause some problem?

"api_key" => base64_decode($dados_config->sistema_key)
  • 1

    In PHP up to 5.6 constants cannot contain arrays.

  • I’m wearing a 7.2

  • Are you sure? In this version this error message should not appear.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.