0% found this document useful (0 votes)
2 views

php exp6 23

The document outlines a laboratory experiment for a web page development course using PHP, focusing on writing simple and parameterized functions. It includes a sample PHP program that demonstrates a basic function, along with practical questions about anonymous functions, built-in vs. user-defined functions, and variable functions. Additionally, it provides exercises for students to apply their understanding by writing PHP programs for various mathematical operations.

Uploaded by

aafu202
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

php exp6 23

The document outlines a laboratory experiment for a web page development course using PHP, focusing on writing simple and parameterized functions. It includes a sample PHP program that demonstrates a basic function, along with practical questions about anonymous functions, built-in vs. user-defined functions, and variable functions. Additionally, it provides exercises for students to apply their understanding by writing PHP programs for various mathematical operations.

Uploaded by

aafu202
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DEPARTMENT OF COMPUTER ENGINEERING

Subject: web page development using php Subject Code: 22619


Semester: 6 Course: CO6I-A
Laboratory No: Name of Subject Teacher: Saqib Ghatte
Name of Student: AFIF IRFAN NAZIR Roll Id: 21203A1005

Experiment No: 6
Title of Experiment Write a simple PHP program to demonstrate use of simple function and
parameterized function.

Program code:
<html>
<head>
<title>Writing PHP Function</title>
</head>
<body>
<?php
/* Defining a PHP Function */
function writeMessage(){
echo "Welcome to PHP world!";
}
/* Calling a PHP Function */
writeMessage();
?>
</body>
</html>

Output:
Welcome to PHP world!
Practical related questions.
1. What is anonymous function?
In PHP, an anonymous function is a function that does not have a name. It is also
known as a closure or a lambda function. An anonymous function can be
assigned to a variable or passed as an argument to another function. It can be
used in situations where you need to create a function quickly without defining it
separately.

2. Write the difference between built in function & user defined function.

The main differences between built-in functions and user-defined functions are
that built-in functions are already included in PHP and optimized for
performance, while user-defined functions need to be defined by the user and
can be customized to meet specific needs.

In summary, built-in functions are part of the PHP core, while user-defined
functions are defined by the user. Both types of functions can be useful in
different situations.

3. What is variable function?


In PHP, a variable function is a function that can be dynamically called using a
variable name. It allows you to call a function whose name is not known until
runtime.

Exercise
1. Write a code to perform addition of 3 numbers using function.
2. Write a PHP program to check whether number is even or odd using function.

3. Write a PHP program to print factorial of number using function.


4. PHP program to check whether a number is prime or Not using function.

You might also like