Professional Documents
Culture Documents
EXERCISE 1:
1. Write PHP program to convert a string, lower to upper case and upper case to
lower case or capital case.
CODE:
SS:
Muhammad Aashir Khan
02-134201-032 lab-9 intro to php
<html>
<body>
<form method="post">
Enter a Number: <input type="text" name="num"/><br>
<button type="submit">Check</button>
</form>
<?php if($_POST)
{
$num = $_POST['num'];
$reverse = strrev($num);
if($num == $reverse){
echo "The number $num is Palindrome";
}else{
echo "The number $num is not a Palindrome";
}
}
?>
</body>
</html>
EXERCISE 2:
Write a php program that generate the marks sheet of a student. Store the information of the
student and its marks using associative array. Display the information in an Html table.
CODE:
<?php
$STUDENT_INFO = array(
'name' => 'Hafsah',
'maths' => 90,
'physics_th' => 60,
'physics_pr' => 18,
Muhammad Aashir Khan
02-134201-032 lab-9 intro to php
}
</style>
</head>
<body>
<div class="container">
<h2>Mark Sheet</h2>
<table>
<thead>
<tr>
<th>No.</th>
<th>Subject Name</th>
<th>Total Marks</th>
<th>Theory</th>
<th>Practical</th>
<th>Obtained Marks</th>
<th>Grade</th>
<tr>
</thead>
<tbody>
<tr>
<td>01</td>
<td>Maths</td>
<td>100</td>
<td><?php echo $STUDENT_INFO['maths'] ?> out of 100</td>
<td></td>
<td><?php echo $STUDENT_INFO['maths'] ?></td>
<td>A+</td>
</tr>
<tr>
<td>02</td>
<td>English</td>
Muhammad Aashir Khan
02-134201-032 lab-9 intro to php
<td>100</td>
<td><?php echo $STUDENT_INFO['english'] ?> out of 100</td>
<td></td>
<td>80</td>
<td>A</td>
</tr>
<tr>
<td>03</td>
<td>Physics</td>
<td>100</td>
<td><?php echo $STUDENT_INFO['physics_th'] ?> out of 80</td>
<td><?php echo $STUDENT_INFO['physics_pr'] ?> out of 20</td>
<td><?php echo ($STUDENT_INFO['physics_th']+
$STUDENT_INFO['physics_pr'])?></td>
<td>B</td>
</tr>
<tr>
<td>04</td>
<td>Chemistry</td>
<td>100</td>
<td><?php echo $STUDENT_INFO['chem_th'] ?> out of 80</td>
<td><?php echo $STUDENT_INFO['chem_pr'] ?> out of 20</td>
<td><?php echo ($STUDENT_INFO['chem_th']+
$STUDENT_INFO['chem_pr'])?></td>
<td>B</td>
</tr>
<tr>
<td>05</td>
<td>Pakistan Studies</td>
<td>100</td>
<td><?php echo $STUDENT_INFO['pst'] ?> out of 100</td>
Muhammad Aashir Khan
02-134201-032 lab-9 intro to php
<td></td>
<td>71</td>
<td>B</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
SS:
EXERCISE 3:
Write an HTML document that includes anchor tag that calls a PHP document. Also write the
called PHP document, which returns a randomly chosen greeting from the a list of five different
Muhammad Aashir Khan
02-134201-032 lab-9 intro to php
greetings. The greetings must be stored as constant strings in the script. A random number
between 0 and 4 can be computed with these lines.
SS: