1.

What are the rules for naming a PHP variable?

Answer»

The following two rules are needed to be followed while naming a PHP variable:

  • A variable must start with a DOLLAR symbol, followed by the variable name. For example: $PRICE=100; where price is a variable name.
  • Variable names must begin with a letter or underscore.
  • A variable name can CONSIST of letters, numbers, or UNDERSCORES. But you cannot use CHARACTERS like + , – , % , & etc.
  • A PHP variable name cannot contain spaces.
  • PHP variables are case-sensitive. So $NAME and $name both are treated as different variables.


Discussion

No Comment Found