Why PHP variables start with $

Source: Internet
Author: User
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 $ .

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.