Refer this introduction , before doing any PHP program.
PHP Introduction - And some useful points in Programming
Rules for PHP variables:
PHP Introduction - And some useful points in Programming
- Open Dreamweaver to write php code , with in the body tag .That is ,
.......................} php code
</body> .
and save it (as .php) under the www directory of wamp server.
- Then click wamp-->localhost to view it in the browser.
=================================================================
<!DOCTYPE html>
<html>
<body>
<?php
$x=5;
$y=6;
$z=$x+$y;
echo $z;
?>
</body>
</html>
Output :
11
========================================================
If we want to display 5, and 6 along with 11, do the program like this:
<!DOCTYPE html>
<html>
<body>
<?php
$x=5;
$y=6;
echo $x ;
echo " +" ;
echo "<br>";
echo $y;
echo "<br>";
echo "..........";
$z=$x+$y;
echo "<br>";
echo $z;
?>
</body>
</html>
Output :
5 +
6
-------
11
6
-------
11
Note :
In PHP these letters (x,y,z etc) are called variables.Variables are "containers" for storing information:Rules for PHP variables:
- 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 ($y and $Y are two different variables)
No comments:
Post a Comment