Multiple choice technology web 2.0

Which one of these variables has a legal name?

  1. $1myvar
  2. $my_var
  3. $my-var
  4. my$var
Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In PHP, variables must start with a dollar sign followed by a letter or underscore. Therefore, $my_var is a legal variable name. $1myvar starts with a digit, \$my-var contains an invalid hyphen, and my\$var does not start with a dollar sign.