Variables in PHP

variable in php

Variable  is  name of memory location   used  to store some  data.

In PHP no need  to provide  data types at the   time of variable  declaration because  PHP is loosely types   language .

Variable names start  with  ‘$’ symbol.

Local variable :-

Variable declaration within  the  function comes under local variable .

Local variable of  a function cannot  be accessed  from another  function.

Global variable :-

Variable declaration outside  of  all function  come under global variable.

Global variable  can be accessed from any function within the script.

Note:-  We  can not access global variables directry from function by using ‘$’ GLOBALS  keyword.  We can access global variable by using  ‘$ GLOBALS’ key from functions.

Variable  variables :-

If we assign a variable name as the value of another variable comes under  variable variables ,

Static variables :-

Static variable can remember previous value . we can assign value only  one time into static variable.

Reference variable  :-

It is an alias name of a variable . both refers the value of same address locations.

Super Global variable :

PHP support no of super global variable . these variable we can access from any  web page in application. All super global variables are array data types available

Join Our WhatsApp Channel Join Now
Join Our Telegram Group Join Now