Can ordinary variables be called as an array?

Hello everyone! Is it possible to name a variable like this, for example:

<? $lang['on'] = '';
$lang['off'] = '';
...
?>

or better yet

<? $on = '';
$off = '';
...
?>

Or does it make no difference? The first option is more convenient for me, but maybe without opening the array – is this a bad option? PS do not put a minus, I’m learning =)


Answer 1, authority 100%

Yes, what’s the problem? Although the option depends on the task. If you just output the value, then both options are possible. If you plan to use, for example, a template engine, then it is better to set variables via an array.


Answer 2

Square brackets already imply an array, so you can’t use them in variable names.


Answer 3

What is the first option, what is the second, are equivalent. If you want to use the first one – use it, it’s not a mistake.


Answer 4

You can use both options.


Answer 5

Optional :

<?php
$v = 's';
$$v = 's var setted';
echo $s;
?>

Answer 6

You can use both. But in large projects, arrays, xml or yaml are better