How can you pass parameters to a PHP function

In PHP, you can pass parameters to a function in several ways. The most common method is to pass them by value, but you can also pass by reference or use default parameters. Here are some examples:

<?php // Function to demonstrate passing parameters by value function greet($name) { return "Hello, " . $name . "!"; } echo greet("Alice"); // Outputs: Hello, Alice! ?> <?php // Function with default parameters function multiply($a, $b = 2) { return $a * $b; } echo multiply(5); // Outputs: 10 echo multiply(5, 3); // Outputs: 15 ?> <?php // Function to demonstrate passing parameters by reference function addFive(&$value) { $value += 5; } $number = 10; addFive($number); echo $number; // Outputs: 15 ?>

PHP function parameters pass by value pass by reference default parameters