PHP Variable

The main way to store information in the middle of a PHP program is by using a Variable.

                                        OR

Variables are the "Container" to store the value.

  • Here are the most important things to know about variables in PHP.
  • All variables in PHP are denoted with a leading dollar sign ($).
  • The value of a variable is the value of its most recent assignment.
  • Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right.
  • Variables can, but do not need, to be declared before assignment.
  • Variables in PHP do not have intrinsic types - a variable does not know in advance whether it will be used to store a number or a string of characters.
  • Variables used before they are assigned have default values.
  • PHP does a good job of automatically converting types from one to another when necessary.
  • PHP variables are Perl-like.

Types of Variables :

Integers are whole numbers, without a decimal point, like 4195.
Doubles are floating-point numbers, like 3.14159 or 49.1.
Booleans have only two possible values either true or false.
NULL is a special type that only has one value: NULL.
Strings are sequences of characters, like 'PHP supports string operations.'
Arrays are named and indexed collections of other values.
Objects are instances of programmer-defined classes, which can package up both other kinds of values and functions that are specific to the class.

Post a Comment

0 Comments