Hello World Function in PHP Code

Hello World Function in PHP Code. This program will help you to understand how the function works in the PHP programming language. A PHP function is a chunk of code that can be reused numerous times. It can take input as an argument list and return value. PHP comes with thousands of built-in functions. Conditional functions, Function within Functions, and Recursive functions can all be defined in PHP.

<?php 
function hello($name)
{
echo "Hello $name<br/>";
}
hello("inlarn");
hello("dotcom");
?>

 

Output:

Hello inlarn

Hello dotcom

Function in PHP

Other programming languages’ functions are similar to PHP’s. A function is a piece of code that takes another input in the form of a parameter, processes it, and then returns a value. Many functions, such as fopen() and fread(), have already been encountered. 

A feature that can be used by end users and is built into an application. Most spreadsheet programs, for example, provide a built-in SUM function that sums up all cells in a row or column. Functions allow you to run the same code numerous times. 2 Functions are used to break down large programs into smaller parts. 3 Other programmers can share and utilise the functions.