0% found this document useful (0 votes)
17 views57 pages

II Cs PHP Record

Uploaded by

ivarkumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views57 pages

II Cs PHP Record

Uploaded by

ivarkumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 57

ARRAY FUNCTION

EX NO: 1

DATE:

AIM:

To write a PHP program for a array function.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING:

A. ARRAY FLIP FUMCTION

<?php

$array = array

"a"=>"apple",

"b"=>"banana",

"o"=>"orange"

);

print_r(array_flip($array));

?>

B. ARRAY COUNT FUNCTION

<?php

$name=array("php","java","html");

$a=count($name);

echo "number of elements in an array:";


echo $a;

?>

C. ARRAY SEARCH FUNCTION

array_search(search_value,$array,option);

<?php

$num=array(20,50,10);

$key=array_search(50,$num);

print_r($num);

echo "<br>key of search no:"key;

?>
D. ARRAY SUM FUNCTION

<?php

$num = array(20,50,10);

echo "sum of array =".array_sum($num);

?>
CONTROL STATEMENTS

EX NO: 2

DATE:

AIM:

To write a PHP program for control statement in if,else-if,while,do-while.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING:

A. IF STATEMNT

<?php

$password="def";

if($password=="def")

echo "access granted.";

$access="allowed";

else

echo "access denied.";

?>

B. ELSE IF STATEMENT

<?php

$a=(rand(1,50));

if($a<="10")
{

echo "you are baby"."<br>";

echo "your age are:".$a."<br>";

else if($a<="20"&&$a>"10")

echo "you are young baby"."<br>";

echo "your age are:".$a."<br>";

else if($a<="35" &&$a>"20")

echo "you are middle age man"."<br>";

echo "your age are:".$a."<br>";

else

echo "you are old man"."<br>";

echo "your age are:".$a."<br>";

?>

Output:
C. WHILE LOOP STATEMENT

<?php

$array=array('audi'=>'a4',

'bmw'=>'x5',

'lamborghini'=>'5-25 2agato',

'maruti'=>'aulto800',

);

echo "car->";

echo "mode"."<br>";

reset($array);

while(list($key,$value)=each($array))

echo "$key->";

echo "$value"."<br>";

?>
D. DO WHILE STATEMENT

<?php

$i=9;

$j=10;

do

echo "first do while loop i=".$i."j=".$j;

echo "<br>";

do

$i++;

echo "second while i=".$i."j=".$j;

echo "<br>";

while($j==5);

while($i==10);

?>
Output
EXNO: 3 ADDING TWO NUMBERS

DATE:

AIM:

Write a PHP program for a adding two numbers.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING:

<html>

<body>

<form method="post">

Enter First Number:

<input type="number" name="number1" /><br><br>

Enter Second Number:

<input type="number" name="number2" /><br><br>

<input type="submit" name="submit" value="Add">

</form>

<?php

if(isset($_POST['submit']))

$number1 =$_POST['number1'];

$number2 =$_POST['number2'];

$sum= $number1+$number2;

echo "The sum of $number1 and $number2 is:".$sum;

?>

</body>

</html>
OUTPUT

RESULT

Thus the above program was executed successfully and was verified.
EXNO: 4 CASCADING STYLE SHEET

DATE:

AIM:

Write a PHP program for cascading style sheet.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING:

<html>
<body>
<h1 style="color:blue;">A Blue Heading</h1>
<p style="color:red;">A red paragraph.</p>
</body>
</html>

<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>

body {
background-color: powderblue;
}
h1 {
color: blue;
}
p{
color: red;
}
OUTPUT:
RESULT:
Thus the program was excuted and verified succesfully.
FUNCTION

EXNO: 5

DATE:

AIM:

Write a PHP program for functions.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING:

A. FUNCTION NO RETURN VALUE

<?php

function myname()

echo "Alex";

myname();

?>

output

B. FUNCTION RETURN VALUE

<?php

echo "My name is ";


myname();
function myname()
{
echo "Alex";

?>
output

RESULT
Thus the above program was executed successfully and output was
verified.
CALCULATOR

EXNO: 6

DATE:

AIM:

Write a PHP program for user login.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING:

<?php

if(isset($_POST['sub']))

$txt1=$_POST['n1'];

$txt2=$_POST['n2'];

$oprnd=$_POST['sub'];

if($oprnd=="+")

$res=$txt1+$txt2;

else if($oprnd=="-")

$res=$txt1-$txt2;

else if($oprnd=="x")

$res=$txt1*$txt2;

else if($oprnd=="/")

$res=$txt1/$txt2;

?>

<form method="post" action="">

Calculator

<br>

No1:<input name="n1" value="<?php echo $txt1; ?>">

<br>

No2:<input name="n2" value="<?php echo $txt2; ?>">


<br>

Res:<input name="res" value="<?php echo $res; ?>">

<br>

<input type="submit" name="sub" value="+">

<input type="submit" name="sub" value="-">

<input typesubmit" name="sub" value="x">

<input type="submit" name="sub" value="/">

</form>

output
INTERFACE

EXNO: 7

DATE:

AIM:

Write a PHP program for interface.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING:

<html>

<body>

<?php

interface Animal {

public function makeSound();

class Cat implements Animal {

public function makeSound() {

echo "Meow";

$animal = new Cat();

$animal->makeSound();

?>

</body>

</html>
OUTPUT

RESULT

Thus the above program was executed and output was verified.
INHERITANCE

EXNO: 8

DATE:

AIM:

Write a PHP program for inheritance

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING:

<html>

<body>

<?php

class Fruit {

public $name;

public $color;

public function __construct($name, $color) {

$this->name = $name;

$this->color = $color;

public function intro() {

echo "The fruit is {$this->name} and the color is {$this->color}.";

// Strawberry is inherited from Fruit

class Strawberry extends Fruit {

public function message() {

echo "Am I a fruit or a berry? ";

$strawberry = new Strawberry("Strawberry", "red");

$strawberry->message();

$strawberry->intro();

?>
</body>

</html>

OUTPUT

RESULT

Thus the above program was executed and output was verified.
CONSTRUCTOR

EXNO: 9

DATE:

AIM:

Write a PHP program for Constructor.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING:

<html>

<body>

<?php

class Fruit {

public $name;

public $color;

function __construct($name) {

$this->name = $name;

function get_name() {

return $this->name;

$apple = new Fruit("Apple");

echo $apple->get_name();

?>

</body>

</html>
OUTPUT

RESULT

Thus the above program was executed and output was verified.
WEBSITE DESIGNING WITH DATABASE CONNECTION

EXNO: 10

DATE:

AIM:

Write a PHP program for Website designing with database connection.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING
<?php

if(isset($_POST['sub']))

$txt1=$_POST['n1'];

$txt2=$_POST['n2'];

$oprnd=$_POST['sub'];

if($oprnd=="+")

$res=$txt1+$txt2;

else if($oprnd=="-")

$res=$txt1-$txt2;

else if($oprnd=="x")

$res=$txt1*$txt2;

else if($oprnd=="/")

$res=$txt1/$txt2;

?>

<form method="post" action="">

Calculator

<br>

No1:<input name="n1" value="<?php echo $txt1; ?>">

<br>

No2:<input name="n2" value="<?php echo $txt2; ?>">


OUTPUT

RESULT

Thus the above program was executed and output was verified.
FILTER

EXNO: 11

DATE:

AIM:

Write a PHP program for Filter

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING

</head>

<body>

<table>

<tr>

<td>filter name</td>

<td>filter id</td>

</tr>

<?php

foreach(filter_list()as $id=>$filter)

echo '<tr><td>'.$filter.'</td><td>'.filter_id($filter).'</td></tr>';

?>

</table>

</body>

</html>
OUTPUT

RESULT

Thus the above program was executed and output was verified.
BIODATA

EXNO: 12

DATE:

AIM:

Write a PHP program for Biodata

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING

<html>

<body>

<h2>Biodata</h2>

<label="a">Name:</label>

<input type="text" id="a" name="a">

<br><br>

<label="a">mother name:</label>

<input type="text" id="a" name="a">

<label="a">mother's occupation:</label>

<input type="text" id="a" name="a">

<br><br>

<label="a">father name:</label>

<input type="text" id="a" name="a">

<label="a">father's occupation:</label>

<input type="text" id="a" name="a">

<br><br>

<label="a">mobile no:</label>

<input type="text" id="a" name="a">

<br><br>
<label="a">address:</label>

<input type="text" id="a" name="a">

<br><br>

<label="a">email id:</label>

<input type="text" id="a" name="a">

<br><br>

<h2>select your gender</h2>

<input type="radio" id="a" name="name">

<label="a">male</label>

<input type="radio" id="a" name="name">

<label="a">female</label>

<input type="radio" id="a" name="name">

<label="a">other</label>

<br><br>

<h2>extra curricular activities</h2>

<input type="checkbox" id="a" name="a">

<label="a">book reading</label>

<input type="checkbox" id="a" name="a">

<label="a">bike riding</label>
<input type="checkbox" id="a" name="a">

<label="a">sports</label>

<br><br>

</body>

</html>

OUTPUT

RESULT

Thus the above program was executed and output was verified.
STATIC WEBSITE CREATION

EXNO: 13

DATE:

AIM:

Write a PHP program for static website creation.

ALGORITHM:

1. Start the notepad++.

2. Type the program.

3. Start WampServer and localhost.

4. Run the program.

5. Result the program.

6. Stop the program.


CODING

A.

<html>

<body>

<center><h1><font color="purple">Nazia College Of Arts & Science</font><h1>

<center><h1><font color="purple">A Unit Of CEOA Group Institution</font><h1>

<center><h1><font color="purple">Kariapatti,virudhunagar-626115</font><h1>

<center><a href="home.html" target="c"><about</font></center><br><br>

<center><a href="courses.html" target="c"><font


color="red">courses</font></center><br><br>

<center><a href="online apply.html" target="c"><font


color="blue">admission</font></center><br><br>

<center><a href="gallery.html" target="c"><font


color=green">gallery</font></center><br><br>

</body>

</html>

B.

<html>

<body>
<center><h1>Nazia College Of Arts & Science<h1>

<center><h1>A Unit Of CEOA Group Institution<h1>

<center><h1>contact no:1234567892<h1>

<center><a href="ss.php" target="c">back</center><br><br>

</body>

</html>

C.

<html>

<body>

<center>courses</center>

<center><h2>UG COURSES</h2></center>

<center><a href="ug courses.html" target="o">UG COURSES</center>

<center><h2>PG COURSES</h2></center>

<center><a href="pg courses.html" target="o">PG COURSES</center>

<center><a href="ss.php" target="c">back</center><br><br>

</body>

</html>
D.

<html>

<body>

<center>

<body background="OIPCAT0VBSZ.jpg">

<h2>B.ATAMIL</h2>

<h2><font color="red">B.A ENGLISH</font></h2>

<h2><font color="red">B.SC MATHS</font></h2>

<h2><font color="red">B.Sc CHEMISTRY</font></h2>

<h2><font color="red">B.Sc PHYSICS</font></h2>

<h2><font color="red">B.Sc COMPUTER SCIENCE</font></h2>

</center>

<center><a href="courses.html" target="i">courses</center>

</body>

</html>
E.

<html>

<body>

<center>

<body background="OIPCAT0VBSZ.jpg">

<h2><font color="orange">M.ATAMIL</font></h2>

<h2><font color="orange">M.A ENGLISH</font></h2>

<h2><font color="orange">M.SC MATHS</font></h2>

<h2><font color="orange">M.Sc CHEMISTRY</font></h2>

<h2><font color="orange">M.Sc PHYSICS</font></h2>

<h2><font color="orange">M.Sc COMPUTER SCIENCE</font></h2>

</center>

<center><a href="courses.html" target="i">courses</center>

</body>

</html>
F.

<html>

<body>

<h2>online application</h2>

<label="a">student name:</label>

<input type="text" id="a" name="a">

<br><br>

<label="a">mother name name:</label>

<input type="text" id="a" name="a">

<br><br>

<label="a">father name:</label>

<input type="text" id="a" name="a">

<label="a">mobile no:</label>

<input type="text" id="a" name="a">

<br><br>

<label="a">aadhaar no:</label>

<input type="text" id="a" name="a">

<br><br>

<h2>select your gender</h2>

<input type="radio" id="a" name="name">


<label="a">male</label>

<input type="radio" id="a" name="name">

<label="a">female</label>

<input type="radio" id="a" name="name">

<label="a">other</label>

<br><br>

<h2>select department<h2>

<select name="a" id="a">

<option value="k">cs</option value>

<option value="k">tamil</option value>

<option value="k">maths</option value>

<option value="k">chemistry</option value>

<option value="k">physics</option value>

<option value="k">english</option value>

<br><br>

<h2>hobbies</h2>

<input type="checkbox" id="a" name="a">

<label="a">book reading</label>

<input type="checkbox" id="a" name="a">

<label="a">bike riding</label>

<input type="checkbox" id="a" name="a">

<label="a">cooking</label>
<br><br>

<center><a href="thankyou.html" target="c">submit</center><br><br>

<center><a href="ss.php" target="c">back</center>

</body>

</html>

G.

<html>

<body>

<body background="teddy bear.jpg">

<center><h1>your registration is successfull</h1></center>

</body>

</html>

H.

<html>

<body>

<img src="santhiya.jpg"><br>

<img src="teddy bear.jpg"><br>

<img src="mathu.jpg"><br>

<img src="guru.jpg"><br>

<center><a href="ss.php" target="s">back</center>


</body>

</html>

OUTPUT
RESULT

Thus the above program was executed and output was verified.

You might also like