1.

How To Pass An Argument To A Function?

Answer»

To pass an argument to a function, you need to:
•Add an argument DEFINITION in the function definition.
•Add a value as an argument when invoking the function.
Here is a PHP SCRIPT on how to use arguments in a function():
<?php
function f2c($f) {
return ($f - 32.0)/1.8;
}
print("CELSIUS: ".f2c(100.0)."\N");
print("Celsius: ".f2c(-40.0)."\n");
?>
This script will print:
Celsius: 37.777777777778
Celsius: -40

To pass an argument to a function, you need to:
•Add an argument definition in the function definition.
•Add a value as an argument when invoking the function.
Here is a PHP script on how to use arguments in a function():
<?php
function f2c($f) {
return ($f - 32.0)/1.8;
}
print("Celsius: ".f2c(100.0)."\n");
print("Celsius: ".f2c(-40.0)."\n");
?>
This script will print:
Celsius: 37.777777777778
Celsius: -40



Discussion

No Comment Found