Understanding Variables
variables are the entities which store data of different types in it. We can change variables, create variables etc. Unlike other languages, first we have to define type of any variable, In php we simple assign values of different data type directly instead of mentioning type explicitly.
String variables
String variables are the sequence of characters
<html> <head> <title>PHP Basics</title> </head> <body> <?php $name = "John "; echo $name; $secondname = "von"; echo $secondname; ?> </body> </html>
Numeric variables
Variables don’t contain just strings—they can contain numbers, too.
<html> <head> <title>PHP Basics</title> </head> <body> <?php $age = 25; echo $age; $age = $age+1; // concat multiple echoes with dot (.) echo "age after 1 year " . $age; ?> </body> </html>