PHP is a Loosely Typed Language it automatically converts
the variable to the correct data type, depending on its value.
- A variable starts with the $ sign, followed by the name of the variable.
- A variable name must 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 ($age and $AGE are two different variables)
<!doctype html> <html> <head> <title> Variables</title> </head> <body> <h1>Variables</h1> <?php $x=121; $y=1.33; $bo=true; $msg=' Welcome to '; $city=' Amritsar '; echo $x; echo '<br>'; echo $y; echo "<br>"; echo $city; echo "<br>"; echo $bo; echo "<br>"; echo $msg.$city; echo "<br>"; echo '$y='.$y; echo "<br> value of x is $x"; echo "<br>"; $el ='<table border="2"><tr><th>sr</th></tr> <tr><td>1</td></tr><tr><td>1</td></tr></table>'; echo $el; ?> </body> </html>
No comments:
Post a Comment