PHP Variables


PHP Variables

 

There are important things to know about PHP variables.

 

A PHP variable is used to store different types of information and data.

PHP is a loosely typed language; we do not need to declare its data type.

PHP used assignment operator (=) to assign a variable value.

 

Rules for declaring PHP variables:

 

  • All variable names must begin with the dollar ($) symbol.
  • A variable name must begin with a letter or an underscore (_).
  • A variable can have an alpha-numeric and an underscore (_).
  • The variable name must not contain a space.

If the variable name is longer than a word, it is separated by an underscore ($php_variable).

 

Syntax:

 

PHP variables

 

Read Also: PHP Interview Questions