PHP... what kind of array/variable is this?

upl8t

Regular Member
Joined
Apr 9, 2008
Messages
475
Reaction score
85
Saw something in some code today that I've never seen before.
PHP:
$_['textname'] = 'Text String';
Anyone know what this is and how/why it's used? It was a file used to assign a bunch of text variables for display in various places on a website.
 
Strange...
Well functions the same way on my home server as a regular variable, so there doesn't seem to be anything obviously special about it.
 
I just dropped it into a file and echo'd it out. It works fine. I just don't know why they're doing it this way.
 
Its regular variable exactly like $myArray, bu the name is _.
They just like short names. In one of my JavaScripts i have a function named _, its good if you use it often.
 
Thanks. I though it might have been some kind of special var. Guess it's easy to type that way.
 
Underscore (_) is a valid variable name. So $_ is valid, just like $foo.

Since, $foo['bar'] is an array named foo with a key named bar, so $_['test'] is an array named _ with a key named test.
 
Could be used for translations, for example.

english.php

$_['firstname'] = "First Name";

french.php

$_['firstname'] = "Premier Nom";

As others mentioned, $_ is just a variable holding an array.
 
Back
Top