PHP

Topic: Functions

How To Pass an Argument to a Function?

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.777777777778Celsius: -40

Browse random answers: