General

PHP Variables

A variable may be a place wherever you’ll be able to store things, like variety, a date, number , or some text . you set text or numbers into variables therefore you’ll be able to retrieve them later, more or less you’ll be able to manipulate them. Variables square measure referred to as variables as a result of the worth that they hold will vary. Hence, variables square measure variable. 🙂

  • All variables in PHP square measure denoted with a number one greenback sign ($).
  • In PHP it is not necessary to declare variables before using them. because PHP is a loosely typed language. It automatically analyzes the values and makes conversions to its correct datatype.
  • After the variable name place an equal ( = ) and then assign the value on it
  • To turn a variable into a variable variable, you put an extra $ put in front of your variable.

The name of a variable can be stored in another variable, allowing it to be accessed dynamically. Such variables are known as variable variables.

Syntax of declaring a variable in PHP

$variable_name=value;  

Remember the Rules to write a PHP variable.

  • You can not give any space between the $ and variable name.
  •  You can not use any special character except _ (underscore).
  • You should not use a _ before the variable name as because its mainly used in PHP for predefined key variable.
  •  Variable name cannot start with a number or special symbols.
  • PHP variables are case-sensitive, so $variable_name and $VARIABLE_NAME both are treated as different variable.

RECOMMENDED ARTICLES





Leave a Reply

Your email address will not be published. Required fields are marked *