PHP Variable Declaration
Here I am using php variable, php variable starts with the $ sign.
<?php
//assign text value in variable
$name = "Jawab Adda";
//assign Int value in variable
$x = 5;
//assign Float value in variable
$y = 10.5;
?>
Important
In the example above PHP variable do not need to declare data type. It automatically converts the variable to the correct data type, depending on its value. In other languages such as C, C++, and Java, the programmer must declare the name and type of the variable before using it.
Rules for PHP variables:
-
A variable should be start with the $ sign, followed by the name of the variable
-
A variable name should be start with a letter or the underscore character
-
A variable name cannot start with a number
-
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
-
Variable names are case-sensitive ($gen and $GEN are two different variables)