+ 1
Why use dollar sign for a variable name?
3 Antworten
+ 3
You use dollar signs in PHP not JS.
+ 3
Php --> $ is required to start a variable name
JS --> $ is valid character for variable name, even at first position or alone ( as is named the main variable/function of JQuery function )
+ 2
This is totally related to language design.
$ sign is required to be first character of the variable name in php language and this makes php interpreter faster to lexical analyze your code and determine which word is a variable name.
$ sign isn't required to be first character of the variable name in Javascript but you can use it if you like.