How to Return Value from PHP Functions - Coding Cyber

How to Return Value from PHP Functions

How to Return Value from PHP Functions

Other Articles in PHP User Defined Functions Section

Quickly Navigate to Other Sections in PHP Tutorials

PHP Basics
PHP Data Types
PHP Advanced Data Types
PHP Logical Statements
PHP Operators
PHP Loops
User Defined Functions in PHP
Useful PHP Functions

PHP Functions with Returning values

Not all functions are used to display message. Some functions need to send value to other statements to execute the code. In such cases, we use return statement.

Example of PHP Functions with Returning values
function sum($x, $y) {
$z = $x + $y;
return $z;
}

echo “5 + 10 = ” . sum(5, 10) . “
“;
echo “7 + 13 = ” . sum(7, 13) . “
“;
echo “2 + 4 = ” . sum(2, 4);

Related Posts
No related posts for this content
Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: