Is this bad practice/can cause problems?
$_SESSION['stuff to keep']
As opposed to calling str_replace()
on the indices.
![]() ![]() ![]() |
Is this bad practice/can cause problems?
As opposed to calling
|
||
|
![]() ![]() ![]() |
This is bad practice, but not because of the space.
Here, your code is silently misbehaving, and the bug can take a while to be found. Good practice is to use a PHP-enforced name, such as a class constant:
You may then define that constant to any constant you find interesting or readable, such as Allowing user-entered text into session keys is, of course, a blatant security fault. |
||
|
![]() ![]() |
It won't cause a problem, but array keys are usually considered like variable names so should be chosen with the same considerations |
||
|
![]() ![]() |
You can do that, it'll work -- and even if I don't generally do it when I set the keys of my arrays "by hand", it sometimes happens when I get the keys from a file (for instance), and I've never had any problem with this. Maybe this could cause some kind of a problem if you are using the |
||
|
![]() ![]() |
Bad practice... Well, I don't do that - but that is just a preference. It is, however, completely legitimate. Cause problems... I don't see anything that would implicitly cause a problem with using spaces in a key. |
||
|
![]() ![]() |
Seems like adding unnecessary whitespace in my opinion... I don't usually use spaces. If you do, though, make sure you quote the array keys. |
||
|