A PHP file is not
always only contains script php, but php script can also be inserted into the
html. The layout of the php script that is inserted into the html should match
the location where we want to display.
Example :
|
<html>
<head>
<title>Price</title>
</head>
<body>
<?php
$price
= 10;
$qty
= 9;
print("you've
spent $qty servings<br>\n");
print("price
$price /servings<br>");
print("you
have to pay ");
print($price
* $qty);
?>
</body>
</html>
|
Although we insert php script fixed storage format *.
Php. Placement on html php script will be very influential at the time of
display. If the PHP script will be called the PHP script should be placed
before the command calling a PHP script.
Example :
|
<html>
<head>
<title>Price</title>
</head>
<body>
<?php
$burgerprice=3;
$sphagetiprice=4;
$burger=2;
$sphageti=3;
?>
<table>
<tr>
<td>Food</td>
<td>qty</td>
<td>Price</td>
</tr>
<tr>
<td>burger</td>
<td><?php
echo $burger ?></td>
<td><?php
echo $burgerprice*$burger </td>
<tr>
<td>Sphageti</td>
<td><?php
echo $sphageti ?></td>
<td><?php
echo $sphagetiprice*$sphageti </td>
</tr>
</table>
</body>
</html>
|
No comments:
Post a Comment