In PHP, function parameters can accept multiple data types. The most common include scalar types, composite types, and some special types. Understanding these types is essential for writing flexible and efficient functions.
function myFunction($name, $age, $hobby) {
echo "Name: $name <br>";
echo "Age: $age <br>";
echo "Hobby: $hobby <br>";
}
$name = "John Doe";
$age = 30;
$hobby = "Programming";
myFunction($name, $age, $hobby);
Name: John Doe
Age: 30
Hobby: Programming
This function demonstrates how to define a simple PHP function that accepts string and integer parameters and outputs the values passed to them. Mastering multiple data types for function parameters helps improve code flexibility and maintainability.