VARIABLE IN PHP
VARIABLE IN PHP
The term variable in PHP is known as the address and it holds the value. The other name for the variable is scaler. Variable assigned any symbolic name to the memory where data is stored.
Data / Value is stored in a variable with the help of EQUAL SIGN =.
So, in a program, there are values that can be used to do some action or processing and these values are stored in the variables.
Most of the time PHP variables hold temporary values in it until unless stored that value in the database.
VARIABLE DECLARATION IN PHP
PHP variable declaration is changed from other programming languages, no need to include files at the top. Just declare a variable where needs to assign a value.
$ Sign is used to declare a variable and the name of the variable is written after it without any space.
PHP VARIABLE DECLARATION EXAMPLE
//php starting tag
$a="WELCOME TO WORLDVIEWIT";
//Variable DECLARATION and VALUE ASSIGNING.
//closing tag of php
In the upper example, we make a variable($
) named "a" which is $a.
Then we assign a value to a variable $a or say that we store a value "Welcome To WORLDVIEWIT" and store 10 into $b and in the $c we stored 99.9.
Things to keep in mind before starting assigning a value to a variable in PHP.
For Text Assigning: Use quotes before text start and after the text end. And terminate the line with a semicolon ; .
For number assigning: Just write the number after the equal sign.
PHP is a case sensitive language. So variables are also cased sensitive like $xyz and $XYZ both are different.
Variable names are made using alphabets(a, z, a-z, A-Z), underscore(_), characters(0-9).
Important Things About PHP Language
In this language no need to use data type before variable declaration as in the upper example we do not label any datatype like other programming languages.
So you can easily add a number (integer) with the text (string) it shows no error.
But in the PHP 7 datatype declaration used so, if appropriate data type not found in the variable it will show type mismatched error or fatal error
- What is 1XBET | Download 1XBET | Affiliate Program 1XBET | Mobile App for ios & android
- Best electronics gadgets of all time on Amazon’s and eBay
- Internship base Short Courses
- CTI JOBS in Punjab Pakistan | 2019-2020
- Google is turning Android Phones into seismometers
- How independence day of Pakistan Celebrated?
- How Scorpion Venom Effects
- Maecenas nec venenatis
- Suspendisse vel eros nulla
- Lacinia quis vel eros donec