Services Work Learn About Contact
0/8
Lesson 6 of 8

Functions

Functions are reusable blocks of code. Define them with the function keyword. You can return values and accept parameters.

PHP
<?php
function greet($name) {
  return "Hello, " . $name;
}

function add($a, $b) {
  return $a + $b;
}

echo greet("Ali"); // "Hello, Ali"
echo add(3, 4);    // 7
?>
🧠

Quick Quiz

Answer correctly to unlock the next lesson.

Support the mission

This learning platform is 100% free: no ads, no tracking, no paywalls. If it helped you learn something useful, you can support future lessons or donate to Doctors Without Borders, which provides emergency medical care in crisis zones worldwide.

🎉

You completed PHP!

You finished all 8 lessons and quizzes. You now know the basics of PHP.