I've never seen something like this in a language, but I'm working with a PHP array and it would quite useful, but more than any thing, I'm curious.
Is it possible for a regular variable to reference itself. For example:
$variable_array = array(1, 2);
$variable_array = array_merge(self, array(3, 4));
or
$variable_string = 'This is a string';
$variable_string = explode(' ', self);
Where self
is the variable itself, like this
is when working with objects. Now, I know someone is going to ask why not just call the variable again, and that is what I normally do in this case. However, for readability when dealing with long names, such as named indexes in arrays, this would be useful.
Does PHP, or any language at all do this or something similar?