Why do PHP variables start with $???
What does $$ mean?
This issue has been closed because of a discussion-based question of non-technical questions
Reply content:
Why do PHP variables start with $???
What does $$ mean?
Because PHP was based on Perl which used $, though the symbols Perl used were meaningful and plenty used to indicate the D ATA type, (such as @ used to indicate a array) PHP just has $
.
PHP in its early stages is a simplistic version of Perl but over time incorporated more of Perl ' s features, though one MA Y argue PHP is still a simplistic primitive version of Perl since to the most installed versions of it don t include Features that has been around in other languages forever, such as closures/namespacing.
Http://en.wikipedia.org/wiki/PHP
Larry Wall, the creator of Perl, was inspired to use from $
shell
Scripting
Http://en.wikipedia.org/wiki/Sigil_%28computer_programming%29
Http://stackoverflow.com/questions/3073812/why-php-variables-start-with-a-sign-symbol
The context in which you say $$ is actually:
$temp = 18;$age = 'temp';echo $$age;
That's it.
This is called a mutable variable, and the variable name itself is also a variable
As for your question of why PHP uses the ID of the variable, then I can only say
Why Java uses main as a program entry
Why Python is strictly indented with 4 spaces
Why go to Fmt.print instead of print, honestly I really want to ask this question
That's the kind of restraint that's going to get from him.
This is the same as why you and your father have a surname ...
PHP dads require it to start with $.
That's because the people who developed PHP like to do this, wayward ...
PHP authors like dollars.
and keyboard convenient input special symbols, other symbols have arithmetic function, @ is mailbox, #注释, also _ and $
convenient input and do not participate in the operation. Obviously, it $
makes people more motivated.
The first question is that it's an agreement, it's the constitution. The program can't run
The second is a mutable variable, that is, the value of the following variable as the name of the variable
Why is PHP used $
?
Because Perl is used $
.
Why is Perl used $
?
Because the "variable" in English is scalar, the first letter S
, and the closest $
is $
.