Defining Function
Defining Functions
Section titled “Defining Functions”Functions are reusable blocks of code that perform specific tasks. They help organize code, reduce repetition, and make programs easier to maintain.
<?php// Basic function definitionfunction sayHello() { echo "Hello, World!";}
// Calling a functionsayHello(); // Hello, World!Function with return value
Section titled “Function with return value”<?phpfunction getGreeting() { return "Hello, World!";}
$message = getGreeting();echo $message; // Hello, World!