Why PHP variables start with a $ sign symbol?

前端 未结 4 1534
南笙
南笙 2020-11-30 07:19

Has anybody ever thought about this question. Why we must write $var_name = value; and not var_name = value;? Yes I know that it is the syntax rule

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 07:42

    This has been common in computer languages for a long time, that's all. Long before Perl, too! For instance, check out Commodore 64 BASIC

    10 PRINT "WHAT IS YOUR NAME?"
    20 INPUT A$
    30 IF A$="BAHKTIYOR" THEN PRINT "HEY CHECK OUT THAT DOLLAR SIGN"
    

    In BASIC the $ was after the variable name, however.

提交回复
热议问题