OST LAB MANUAL
OST LAB MANUAL
PROGRAM
<html>
<head> </head>
<body>
<?php
function fact($n)
$f=1;
for($i=1;$i<$n;$i++)
$f=$f*$i;
return($f);
echo '<br>';
echo '-----------------------------';
echo '<br>';
$n=5;
$k=fact($n);
?>
</body>
</html>
OUTPUT
8. write a php program using user-defined and pre-defined function
PROGRAM:
<?php
function calculateFactorial($num) {
if ($num < 0) {
$factorial = 1;
$factorial *= $i;
return $factorial;
$nameLength = strlen($name);
$uppercaseName = strtoupper($name);
// Display results
PROGRAM:
<?php
$greeting = "Hello";
$name = "John";
echo $fullMessage;
?>
OUTPUT:
PROGRAM:
<?php
// Define a string
$textLength = strlen($text);
$reversedText = strrev($text);
$uppercaseText = strtoupper($text);
$lowercaseText = strtolower($text);
// Displaying results
?>
11. write a php program using indexed array,assosiative array and multi dimensional array
PROGRAM:
<?php
// Indexed Array
// Associative Array
$student = array(
);
// Multidimensional Array
$students = array(
);
?>
OUTPUT:
Apple
Banana
Cherry
Age: 20
PROGRAM:
<?php
// Define a class
class Car {
public $brand;
public $color;
$this->brand = $brand;
$this->color = $color;
$car1->setDetails("Toyota", "Red");
$car1->getDetails();
?>
OUTPUT:
PROGRAM:
<?php
// Define a class
class Person {
public $name;
public $age;
// Constructor
$this->name = $name;
$this->age = $age;
// Create an object
echo "<b>Introspection:</b><br>";
print_r(get_object_vars($person1));
print_r(get_class_methods($person1));
echo "<br><br>";
$serializedData = serialize($person1);
$unserializedPerson = unserialize($serializedData);
$unserializedPerson->display();
?>
OUTPUT:
Introspection:
Age: 30