हिंदी

PHP Variables

Advertisements
  • Rules for declaring PHP Variable
  • Different variable scopes in PHP

PHP Variables

Variable is a symbol or name that stands for a value. Variables are used for storing values such as numeric values, characters, character strings, or memory addresses, so that they can be used in any part of the program. 

Rules for declaring PHP Variable 

A variable name starts with $ sign. A variable name should not start with a digit. Variable names are case insensitive.     

Different variable scopes in PHP 

  1. Local: A variable declared within a function has a LOCAL SCOPE and can only be accessed within that function  
  2. Global: A variable declared outside a function has a GLOBAL SCOPE and can only be accessed outside a function. 
  3. Static: When a function is executed, all its variables are deleted. If we want a local variable not to be deleted, then the use of "static" keyword is must. 
If you would like to contribute notes or other learning material, please submit them using the button below.
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×