Courses Job Ready Fresher Training AI for Class 7 to 12 Corporate Training Placements Tutorials
Free Learning Resources

IT Tutorials & Interview Prep

Free guides, interview Q&As, and job responsibility breakdowns — curated by industry veterans to help you crack MNC interviews

109+
Tutorial Articles
9
Topic Categories
100%
Free to Read
← Back to PHP

PHP Function

PHP Last Updated: Oct 17, 2025

Function Basics

Function arguments are variables of some supported data type that are processed within the body of the function. It can take input as an argument and return value.

PHP has more than 1000 built-in functions, and in addition, you can also create your own functions.

Advantages:

  1. Functions reduce the complexity of a program and give it a modular structure.
  2. A function can be defined only once and called many times.
  3. It saves a lot of code writing because you don't need to write the same logic multiple times, you can write the logic once and reuse it.

Built-in Functions: PHP has thousands of built-in functions. For a complete reference and examples, you can go to this link https://www.php.net/manual/en/funcref.php.

User Defined Functions: Apart from built-in functions, we can also create our own functions and call them easily.

A user-defined function looks something like this:

<?php 
function functionname() {
   // Code
}
functionname(); // Calling Function
?>

Example:

<?php
function helloMsg() {
   echo "Hello world!";
}
helloMsg(); // call the function
?>

Want to practice these scenarios in a real IT environment? Our 45-Day Internship Program gives you hands-on experience with Active Directory, Ticketing Tools, and Networking.
Join the Internship →