answersLogoWhite

0

Below is a simple example of how you could return a value in a PHP function.

<?php

function returnme($value)

{

return $value;

}

echo returnme('hello'); // outputs: hello

?>

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is the correct way to create a function in php?

function myFunction($parameter1, $parameter2) { // this function's code goes here return $returnValue; // the value returned }


What are the disavdvantges of PHP?

Its function naming and parameter order/return values are inconsistent


What is a PHP function?

Functions are basic blocks of code that work together. Functions can be used from the core PHP or can be created by users. To create a function, use the following syntax: function function_name(arg1, arg2, ... argX) { //Any valid php code here } To use a function, use the following syntax: function_name(arg1, arg2, ... argX);


Is function always return a value?

no, every function can not return a value. for example void name() { cout&lt;&lt;"Hello world"; } this function does not return any value due to the key word void that tells the compiler that the function does not returns a value.


How do you pass a variable by value in php?

In the declaration of the receiving function, you add an ampersand. &lt;?php function myWayCoolFunction( &amp;$params) {.....} $x = array('1','2','3'); myWayCoolFunction($x) ?&gt;


PHP program for electrical bill calculation?

&lt;?php function calculate_electric_bill( $cost_per_kilowatt, $killowatts_used ) { return $cost_per_kilowatt * $kilowatts_used; } echo calculate_electric_bill( 0.01, 1000 );


What part of a function definition specifies the data type of the value that the function returns?

The function header. The return value is written before the name of the function. This return type must match the type of the value returned in a return statement.


How crearte a function in php?

The simplest way (the old procedural way) is to just declare the function: function ourSimpleFunction(){ //Function Guts } Functions do not require a return type, or typed arguments in PHP, however you can use type-hinting if it makes you feel better.


What statement returns a value from a function?

return


How do you echo the return value of a function?

echo function();


What statement do you need to include in a value-returning function?

In a value-returning function, you need to include a &quot;return&quot; statement to specify the value that the function should return back to the caller.


What is a return statement used for?

It means end the function. Functions automatically end when execution reaches the end of the function, but you can return from a function at any point within the function with a return statement. If the function returns a value to its caller, you must provide a reachable return statement along with the value you wish to return.