IT Questions and Answers :)

Sunday, August 25, 2019

What is the variable symbol in PHP programming?

What is the variable symbol in PHP programming?

  • ?
  • %
  • $
What is the variable symbol in PHP programming?

EXPLANATION


The leading $ symbol before a variable name is called a sigil. Its purpose is to make it clear that the name following the sigil is a variable and not something else, like a function name or a constant or a keyword. Sigils remove ambiguity to make the programming language interpreter's job easier.
Many other programming languages use the $ sigil in similar ways, to denote a variable that holds a single string.
  • Perl dates back to 1987.
  • Shell scripting languages date back to 1979.
  • BASIC dates back to 1964.
So the answer of why PHP uses $ is:
  1. For practical reasons because the language needs some way to distinguish variables from other syntax elements like functions, constants, and keywords.
  2. Because it’s traditional and familiar to many programmers to use $ as a sigil for variables.

 

Share:

0 comments:

Post a Comment

Popular Posts