Q 1 Write A Simple HTML Code To Develop HTML Page
Q 1 Write A Simple HTML Code To Develop HTML Page
<!DOCTYPE html>
<html>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="Address">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
output :
This is a heading
This is a paragraph.
<!DOCTYPE html>
<html>
<head>
<style>
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Output
This is a heading
This is a paragraph.
<?php
$x = 5;
$y = 10.5;
?>
output
Hello world!
10.5
<?php
echo "This ", "string ", "was ", "made ", "with multiple parameters.";
?>
<html>
<body>
<?php
?>
</body>
</html>
output
12
<html>
<body>
<?php
?>
</body>
</html>
output
<!DOCTYPE html>
<html>
<body>
<?php
?>
</body>
</html>
Output
!dlrow olleH
<!DOCTYPE html>
<html>
<body>
<?php
?>
</body>
</html>
Output
<!DOCTYPE html>
<html>
<body>
<?php
echo GREETING;
?>
</body>
</html>
<body>
<?php
$t = date("H");
?>
</body>
</html>
<html>
<body>
<?php
$t = date("H");
} else {
?>
</body>
</html>
<?php
$favcolor = "red";
switch ($favcolor) {
case "red":
break;
case "blue":
break;
case "green":
break;
default:
}
?>
Output
<html>
<body>
<?php
$x = 1;
while($x <= 5) {
$x++;
?>
</body>
</html>
Output
<html>
<body>
<?php
$x = 1;
do {
echo "The number is: $x <br>";
$x++;
?>
</body>
</html>
output:
<!DOCTYPE html>
<html>
<body>
<?php
?>
</body>
</html>
output:
<html>
<body>
<?php
function writeMsg() {
writeMsg();
?>
</body>
</html>
Output:
Hello world!
<html>
<body>
<?php
function familyName($fname) {
familyName("Jani");
familyName("Hege");
familyName("Stale");
familyName("Kai Jim");
familyName("Borge");
?>
</body>
</html>
Output:
Jani Refsnes.
Hege Refsnes.
Stale Refsnes.
Borge Refsnes.
<html>
<body>
<?php
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
</body>
</html>
output
<html>
<body>
<?php
?>
</body>
</html>
output:
Simple.html
<html>
<body>
<input type="submit">
</form>
</body>
</html>
welcome.php
<html>
<body>
</body>
</html>
output:
Welcome mk
Simple.php
<html>
<body>
<input type="submit">
</form>
</body>
</html>
welcome_get.php
<html>
<body>
</body>
</html>
output:
Welcome mk
<?PHP
class Book{
var $title="books";
var $numPages=1;
function setNumPages($numOfPages){
$numPages = $numOfPages;
}
function getNumPages(){
return $numPages;
function setTitle($Title){
$title = $Title;
function getTitle(){
return $title;
?>
output:
books
class Foo
?>
'PHP is great'
'Bar: baz'
'PHP is great'
Q.19 Write a php Script to Create Polymorphism.
<?php
class Shap
function draw(){}
function draw()
function draw()
{
function draw()
$Val=array(2);
$Val[0]=new Circle();
$Val[1]=new Triangle();
$Val[2]=new Ellipse();
for($i=0;$i<3;$i++)
$Val[$i]->draw();
?>
output:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
// Check connection
if (!$conn) {
?>
output:
Connected successfully
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "Employee";
// Create connection
// Check connection
if ($conn->connect_error) {
} else {
$conn->close();
?>
output:
?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "Employee";
// Create connection
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " .
$row["lastname"]. "<br>";
} else {
mysqli_close($conn);
?>
out
joe
?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
// Check connection
if (!$conn) {
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " .
$row["lastname"]. "<br>";
} else {
echo "0 results";
mysqli_close($conn);
?>
output:
data deleted
<html>
<body>
<?php
echo readfile("c:\mk.txt");
?>
</body>
<?php
echo fread($myfile,filesize("webdictionary.txt"));
fclose($myfile);
?>
</html>
Q.22 Write a php Script to check End-Of-File - feof()
<?php
while(!feof($myfile)) {
echo fgets($myfile) . "<br>";
fclose($myfile);
?>
<?php
while(!feof($myfile)) {
echo fgetc($myfile);
fclose($myfile);
?>
<?php
fwrite($myfile, $txt);
fwrite($myfile, $txt);
fclose($myfile);
?>