This question already has an answer here:
hello in my PHP file i got error on host for this line that defines const array:
const telegram_methods=['sendMessage'=>'sendMessage','answerCallbackQuery'=>'answerCallbackQuery','forwardMessage'=>'forwardMessage'];
after some changes in host configurations. the error is:
Parse error: syntax error, unexpected '[' in /........./st_datas.php on line 8
what is the problem of this line or host configurations? and this post: PHP Parse/Syntax Errors; and How to solve them? is so general and not duplicate of my question.
</div>
Maybe for your php version. If your php version >= 5.4, you can use brackets to define array.
So try it:
const telegram_methods = array('sendMessage'=>'sendMessage','answerCallbackQuery'=>'answerCallbackQuery','forwardMessage'=>'forwardMessage');
const telegram_methods=array('sendMessage'=>'sendMessage','answerCallbackQuery'=>'answerCallbackQuery','forwardMessage'=>'forwardMessage');
In regards to your follow up question (arrays are not allowed in class constants) it means simply as it says.
This has been updated in PHP 7 but before then if you need to set a class variable as an array simply drop the constant.
Check out the comments here for a more detailed response.