1 Write a PHPscript to print “hello world”.
2 Write a PHPscript to find odd or even number from given number.
3 Write a PHPscript to find maximum of three numbers.
4 Write a PHPscript to swap two numbers.
5 Write a PHPscript to find the factorial of a number.
6 Write a PHPscript to check whether given number is palindrome or not.
7 Write a PHP script to reverse a given number and calculate its sum
8 Write a PHP script to to generate a Fibonacci series using Recursive function
9 Write a PHP script to implement atleast seven string functions.
10 Write a PHP program to insert new item in array on any position in PHP.
11 Write a PHP script to implement constructor and destructor
12 Write a PHP script to implement form handling using get method
13 Write a PHP script to implement form handling using post method.
14 Write a PHP script that receive form input by the method post to check the number is
prime
or not
15 Write a PHP script that receive string as a form input
16 Write a PHP script to compute addition of two matrices as a form input.
17 Write a PHP script to show the functionality of date and time function.
18 Write a PHP program to upload a file
19 Write a PHP script to implement database creation
20 Write a PHP script to create table
21 Develop a PHP program to design a college admission form using MYSQL database.
1 Write a PHPscript to print “hello world”.
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP
page</h1>
<?php
$string = "Hello World
<br> ";
echo $string;
print $string;
printf("%s", $string);
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP
page</h1>
<?php
$string = "Hello World
<br> ";
echo $string;
print $string;
printf("%s", $string);
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP
page</h1>
<?php
$string = "Hello World
<br> ";
echo $string;
print $string;
printf("%s", $string);
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP
page</h1>
<?php
$string = "Hello World
<br> ";
echo $string;
print $string;
printf("%s", $string);
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP
page</h1>
<?php
$string = "Hello World
<br> ";
echo $string;
print $string;
printf("%s", $string);
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP
page</h1>
<?php
$string = "Hello World
<br> ";
echo $string;
print $string;
printf("%s", $string);
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP
page</h1>
<?php
$string = "Hello World
<br> ";
echo $string;
print $string;
printf("%s", $string);
?>
</body>
</html>
!DOCTYPE html>
<html>
<body>
<h1>
<?php
$string = "Hello World ";
echo $string;
//print $string;
//printf("%s", $string);
?>
</h1>
</body>
</html>
2 Write a PHPscript to find odd or even number from given number.
<html>
<body>
<form method="post">
Enter a number:
<input type="number" name="number">
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
if($_POST){
$number = $_POST['number'];
//divide entered number by 2
//if the reminder is 0 then the number is even otherwise the number is odd
if(($number % 2) == 0){
echo "$number is an Even number";
}else{
echo "$number is Odd number";
?>
3. Write a PHPscript to find maximum of three numbers.
<?php
// Input the three numbers
// and store it in variable
$number1 = 12;
$number2 = 7;
$number3 = 15;
// Using the max function to find the largest number
$maxNumber = max($number1, $number2, $number3);
echo "The largest number among three is: $maxNumber\n";
?>
Or
<?php
// Input the three numbers
// and store it in variable
$number1 = 12;
$number2 = 7;
$number3 = 15;
// Using the max function to find the largest number
if ($number1 > $number2 && $number1 > $number3) {
echo "The largest number is: $number1\n";
} elseif ($number2 > $number1 && $number2 > $number3) {
echo "The largest number is: $number2\n";
} else {
echo "The largest number is: $number3\n";
}
?>
4 Write a PHPscript to swap two numbers.
i. Using a third variable
1. <?php
2. $a = 45;
3. $b = 78;
4. // Swapping Logic
5. $third = $a;
6. $a = $b;
7. $b = $third;
8. echo "After swapping:<br><br>";
9. echo "a =".$a." b=".$b;
10. ?>
Or
ii. Without using a third variable
1. <?php
2. $a=234;
3. $b=345;
4. //using arithmetic operations + and -
5. $a=$a+$b;
6. $b=$a-$b;
7. $a=$a-$b;
8. echo "Value of a: $a</br>";
9. echo "Value of b: $b</br>";
10. ?>
Or
1. <?php
2. $a=234;
3. $b=345;
4. // using arithmetic operations * and /
5. $a=$a*$b;
6. $b=$a/$b;
7. $a=$a/$b;
8. echo "Value of a: $a</br>";
9. echo "Value of b: $b</br>";
10. ?>
5 Write a PHPscript to find the factorial of a number.
1. <?php
2. $num = 4;
3. $factorial = 1;
4. for ($x=$num; $x>=1; $x--)
5. {
6. $factorial = $factorial * $x;
7. }
8. echo "Factorial of $num is $factorial";
9. ?>
Or
1. <html>
2. <head>
3. <title>Factorial Program using loop in PHP</title>
4. </head>
5. <body>
6. <form method="post">
7. Enter the Number:<br>
8. <input type="number" name="number" id="number">
9. <input type="submit" name="submit" value="Submit" />
10. </form>
11. <?php
12. if($_POST){
13. $fact = 1;
14. //getting value from input text box 'number'
15. $number = $_POST['number'];
16. echo "Factorial of $number:<br><br>";
17. //start loop
18. for ($i = 1; $i <= $number; $i++){
19. $fact = $fact * $i;
20. }
21. echo $fact . "<br>";
22. }
23. ?>
24. </body>
25. </html>
6 Write a PHPscript to check whether given number is palindrome or not.
1. <?php
2. function palindrome($n){
3. $number = $n;
4. $sum = 0;
5. while(floor($number)) {
6. $rem = $number % 10;
7. $sum = $sum * 10 + $rem;
8. $number = $number/10;
9. }
10. return $sum;
11. }
12. $input = 1235321;
13. $num = palindrome($input);
14. if($input==$num){
15. echo "$input is a Palindrome number";
16. } else {
17. echo "$input is not a Palindrome";
18. }
19. ?>
7 Write a PHP script to reverse a given number and calculate its sum
8 Write a PHP script to to generate a Fibonacci series using Recursive function
9 Write a PHP script to implement atleast seven string functions.
10 Write a PHP program to insert new item in array on any position in PHP.