0Pricing
PHP Academy · Lesson

Passing Arguments to Functions

Learn how to pass data into functions.

1

Passing Arguments to Functions

Welcome to the next lesson! In this lesson, you’ll learn the different ways to pass arguments to functions in PHP. This flexibility allows you to control how data is handled within your functions. Let’s get started!

Passing Arguments to Functions — illustration 1

2

What Are Function Arguments?

Arguments are values passed to a function when it is called. They allow functions to perform tasks dynamically. Example:

Tip: Specify arguments in parentheses when defining and calling functions.

<?php
  function greet($name) {
    echo "Hello, $name!";
  }

  greet("Alice"); // Outputs: Hello, Alice!
?>

All lessons in this course

  1. What Are Functions?
  2. Built-in Functions
  3. User-Defined Functions
  4. Passing Arguments to Functions
  5. Return Values
← Back to PHP Academy