How to define variable in php


To define variable in php '$' sign is used followed by variable name. Unlike other programming language in php we don't need to define the data type of the variable it get auto assigned whether it is string value or integer value or floating value depending upon the value assigned to variable  by the user. This will very clear while seeing the example below.

Example
<!DOCTYPE html>
<html>
<head><title>expertcoding.com</title>
</head>
<body>
<?php
echo $example = "hello world";     // string value
echo $example1 = 10 ;                 // integer  value
echo $example2 = 10.03;            // floating value
?> 
</body>
</html>
 We can clearly see that we don't  need to define the data type it get auto defined according to the value assigned to the variable by the user.

Output
hello world
10
10.03