All Posts

PHP Functions

PHP Functions

A PHP function is a block of code designed to perform a specific task. Once a function is defined, you can call it anywhere in your script to execute that code block, which helps reduce code redundancy.

PHP Functions are defined using the function keyword and can return a value.

Example

A simple PHP function  example is shown below:

 

<?php

function greet ($name) {

return "Hello, ".  $name. "!";

}

echo greet("John");

?>

 

PHP Tutorials

PHP Tutorials on this website: