PHP Lab Programs CZCA
PHP Lab Programs CZCA
Write a HTML program to demonstrate text formatting working with Image and Hyperlinks.
Aim: To write an HTML program to demonstrate text formatting working with Image and
Hyperlinks.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Formatting Text in HTML</title>
</head>
<body align="center">
<p>This is <b>Bold text</b></p>
<p>This is <strong>Strong text</strong></p>
<p>This is <i> This is Italic Text</i></p>
<p>This is <em> Emphasised text</em></p>
<p>This is <code>computer code</code></p>
<p>This is <small>Smaller text</small></p>
<p>This is <sub>subscripted Text</sub></p>
<p>This is <sup>superscripted Text</sup></p>
<p>This is <del> Deleted Text</del></p>
<p>This is <ins>Inserted Text</ins></p>
<p>This is hyperlink<a href="https://loyoladegreecollegeysrr.ac.in/'' >Click here
</a></p>
<p>This is image <img
src="C:\Users\user\Downloads\pexels-fbo-media-17331157.jpg" alt="picture of car">
</p>
</body>
</html>
Output :
1
This is subscripted Text
This is image
Program 2:
Source Code :
<!DOCTYPE html>
<html>
<body bgcolor="lightblue" >
<center>
<h2>Student marks sheet</h2>
<table border="1" cellspacing="5">
<caption>Input marks</caption>
<tr>
<th rowspan="2">Name</th>
<th colspan="5">Scores</th>
</tr>
<tr>
<th>Zoology</th>
<th>Chemistry</th>
<th>c language</th>
<th>Maths</th>
<th>Java</th>
</tr>
<form>
<tr>
<td> <label for="studentName">Student Name:</label>
<input type="text" id="studentName" name="studentName" required><br></td>
2
<td> <label for="subject2">Subject 2:</label>
<input type="number" id="subject2" name="subject2" required><br></td>
<script>
function calculateMarks() {
var subject1 = parseInt(document.getElementById("subject1").value) || 0;
var subject2 = parseInt(document.getElementById("subject2").value) || 0;
var subject3 = parseInt(document.getElementById("subject3").value) || 0;
var subject4 = parseInt(document.getElementById("subject4").value) || 0;
var subject5 = parseInt(document.getElementById("subject5").value) || 0;
document.getElementById("totalMarks").innerText = totalMarks;
document.getElementById("averageMarks").innerText = averageMarks.toFixed(2);
}
</script>
</body>
</html>
3
Output :
Program 3:
Source code :
<!DOCTYPE html>
<html>
<head>
<?php
$collegeName = "loyola degree college";
echo "<p>Original: $collegeName</p>";
$uppercase = strtoupper($collegeName);
echo "<p>Uppercase: $uppercase</p>";
$lowercase = strtolower($collegeName);
4
echo "<p>Lowercase: $lowercase</p>";
$firstChar = $collegeName[0];
echo "<p>First Character: $firstChar</p>";
$length = strlen($collegeName);
echo "<p>Length: $length</p>";
$reversed = strrev($collegeName);
echo "<p>Reversed: $reversed</p>";
?>
</body>
</html>
Output :
Program 5:
Write an HTML program to perform all arithmetic operations using Java scripts(JS).
Aim : To write an HTML program to perform all arithmetic operations using Java
scripts(JS).
Source code:
<!DOCTYPE html>
<html>
<head>
<title>Arithmetic Operations</title>
</head>
5
<body bgcolor="yellow">
<center>
<h2>Arithmetic Operations</h2>
<script>
function add() {
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var result = num1 + num2;
document.getElementById('result').innerText = 'Result: ' + result;
}
function subtract() {
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var result = num1 - num2;
document.getElementById('result').innerText = 'Result: ' + result;
}
function multiply() {
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var result = num1 * num2;
document.getElementById('result').innerText = 'Result: ' + result;
}
function modulo() {
6
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var result = num1 % num2;
document.getElementById('result').innerText = 'Result: ' + result;
}
</script>
</body>
</html>
Output :
Program 6:
Aim : To develop a HTML program from which accepts any Mathematical expression.
Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Mathematical Expression </title>
</head>
<body>
<center>
7
<h2>Mathematical Expressions</h2>
<label for="expression">Enter Mathematical Expression:</label>
<input type="text" id="expression" placeholder="e.g., 2 + 3 * (4 - 1)"> <br> <br>
<button onclick="evaluateExpression()">Calculate</button>
<script>
function evaluateExpression() {
var expression = document.getElementById('expression').value;
try {
var result = eval(expression);
document.getElementById('result').innerText = 'Result: ' + result;
} catch (error) {
document.getElementById('result').innerText = 'Invalid Expression';
}
}
</script>
</body>
</html>
Outline :
8
9