What kind of variable is this in PHP $_['entry_store'] = 'Stores:';
used in OpenCart
Is used for saving string of text.
For example like this... Is it a global variable, or what is it ? it begins with $_['SomeName];
<?php
$_['heading_feedback']= 'Feedback';
$_['heading_feedback_author']= 'Feedback';
$_['text_success'] = 'Success: You have modified feedback!';
$_['text_default'] = 'Default';
No, it's not a global variable. It's a regular variable with the name _
, and it's an array.
$_ = array();
$_['array_key'] = 'value';
Variables can be named in almost any way, the only limitation is the parser, and _
is not a character that blocks that (for example ${0}
is a valid variable declaration)
Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
PHP doesn't prevent the variable $_
from being an array. For example,
$_ = array('foo' => 'bar');
echo $_['foo']; // bar
works correctly, as does $_foo
or any other non-reserved name.
Let's go back to basics. A snippet from the docs.
A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores
The variable $_
is not a global variable, it's a regular one (with a poor naming convention).