I know it’s possible to set custom PHP variables using the $_ prefix, however I am unsure if it is safe to do this? I wouldn’t be setting many, nor would I be overwriting pre-set variables like $_SERVER or $_COOKIE. Should I just avoid doing it at all?
Share
It is completely safe to initialize variables that start with
$_as long as you don’t override any of the superglobals (that you need).However, the
$_prefix on variables indicates that they are superglobals or have some other kind of magic behavior, so to do so on “normal” variables would be nonstandard.