note 78757 added to language.functions

From: Date: Fri, 26 Oct 2007 06:56:34 +0000
Subject: note 78757 added to language.functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-131745@lists.php.net to get a copy of this message
<?php /* Example of a simple arithmatic function returning mutliple values of variables retrning outside of a function by means of an array. */ $a = null;// variable definition and initial value assignment. $b =null; // variable definition and initial value assignment. function arithmatic($a,$b)// Here $a and $b as function argument - operands (to be operated upon. { global $sum; // global makes variable $sum available outside the function. global $array; // global makes variable $sum available outside the function. $sum = $a + $b; $dif = $a - $b; $mul = $a * $b; $div = bcdiv($a,$b,2);// division precision with 2 decimal points. $array = array($a, $b, $sum, $dif, $mul, $div); return $array; } arithmatic(11,5); // function call by values of $a and $b list($a, $b, $sum, $dif, $mul, $div) = $array; echo "$a plus $b equals to $sum.\n<br>"; echo "$a minus $b equals to $dif.\n<br>"; echo "$a multiplied by $b equals to $mul.\n<br>"; echo "$a divided by $b equals to $div.\n<br>"; /* This generates following output : 11 plus 5 equals to 16. 11 minus 5 equals to 6. 11 multiplied by 5 equals to 55. 11 divided by 5 equals to 2.20. */ ?> ---- Server IP: 69.147.83.197 Probable Submitter: 208.72.122.15 ---- Manual Page -- http://www.php.net/manual/en/language.functions.php Edit -- https://master.php.net/note/edit/78757 Del: integrated -- https://master.php.net/note/delete/78757/integrated Del: useless -- https://master.php.net/note/delete/78757/useless Del: bad code -- https://master.php.net/note/delete/78757/bad+code Del: spam -- https://master.php.net/note/delete/78757/spam Del: non-english -- https://master.php.net/note/delete/78757/non-english Del: in docs -- https://master.php.net/note/delete/78757/in+docs Del: other reasons-- https://master.php.net/note/delete/78757 Reject -- https://master.php.net/note/reject/78757 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131745) next »