Documente Academic
Documente Profesional
Documente Cultură
<?php
print("Hello, world. <BR>");
print("PHP is neato. <BR>");
print("4+8 <BR>");
print(4+8);
print("<BR>");
$total = 4+8;
print("$total <BR>");
?>
Compare the web browser view line by line with the PHP source code. Answer the following questions:
View in http://localhost/xampp/lisa/lab_1.php
("4+8")
(4+8)
Question 2
form.php
<html>
<head>
</head>
<body>
This script demonstrates passing values within an array.
<p>
<form method="post" action="process.php">
<?php
<input type=submit>
</form>
</body>
</html>
process.php
<html>
<head>
</head>
<body>
This script demonstrates using values which
were passed in an array.
<p>
<?php
$vals = $HTTP_POST_VARS["vals"];
$sum = 0;
for ($i = 0; $i < 3; ++$i)
{
echo "Value $i: $vals[$i].<br>\n";
$sum += $vals[$i];
}
echo "<p>The sum of those three numbers is $sum.\n";
?>
</body>
</html>
The first PHP script should generate a form which allows the user to input 10 numbers.
1) When the forms submit button is pressed, the 10 numbers should be sent to the second PHP
script as an array.
<html>
<head>
</head>
<body>
<center>
<body background="cute_girl1.jpg" style="background-attachment:fixed ; background-position:center ;
color:#0099FF; font-family:Caduceus ; margin-top:100px">
This script demonstrates passing values within an array.
<p>
<form method="post" action="process.php">
<?php
$labels = array
("First", // This will ask user to enter first number
"Second", // This will ask user to enter second number
"Third" , // This will ask user to enter third number
"Fourth" , // This will ask user to enter fourth number
"Fifth" , // This will ask user to enter fifth number
"Sixth" , // This will ask user to enter sixth number
"Seventh" , // This will ask user to enter seventh number
"Eighth" , // This will ask user to enter eighth number
"Nineth" , // This will ask user to enter nineth number
"Tenth"); // This will ask user to enter tenth number
New coding for display the largest number and the average of the 10 numbers
<html>
<head>
</head>
<body>
<center>
<body background="cute_girl1.jpg" style="background-attachment:fixed ; background-position:center ;
color:#0099FF; font-family:Copyshop ; margin-top:100px ; margin-right:120px">
This script demonstrates using values which were passed in an array.
<p>
<?php
$vals = $HTTP_POST_VARS["vals"]; // declaration value that enter by the user
$sum = 0; // declaration total sum of the value
$max = $vals[0]; // declaration for the largest value that enter by the user
$min = $vals[0]; // declaration for the smallest value that enter by the user
}
// Display output
echo "<p>The sum of those 10 numbers is $sum.\n";
echo "<p>The average of those 10 numbers is $avg.\n";
echo "<p>The largest of those 10 numbers is $max.\n";
echo "<p>The smallest of those 10 numbers is $min.\n";
?>
</body>
</html>
View in http://localhost/xampp/lisa/process.php