think of a function as a process that takes in a specified set of information and returns you a value based on a commonly used set of calculations
you were very close with your example you just need to actually make use of the returned value
PHP Code:
if (isset($_GET["hemming"]) && ($_GET['calc'] == "yes")) {
$width = $_GET['width'];
$length = $_GET['length'];
$size = $width*$length*4.99;
$hemm = $width*$length*2.99+$size;
$price = $hemm;
needs to be
PHP Code:
if (isset($_GET["hemming"]) && ($_GET['calc'] == "yes")) {
$size = get_my_size($_GET['width'], $_GET['length'],'4.99');
$hemm = $width*$length*2.99+$size;
$price = $hemm;
while including your function on the same page -- prob don;t use size as a function name it's too generic a word and may cause problems somewhere.. dunno where but i just wouldn't use it
PHP Code:
function get_my_size($width, $length, $calValue) {
$width = $_GET['width'];
$length = $_GET['length'];
$size = $width*$length*$calValue;
return $size;
}
if you want to make the function available for other scripts you need to put it in it's own page and then require_once(); that page at the top of the scripts that need access to it or other functions you have in your library
you can now use the same function to calculate the hemm size too
PHP Code:
$hemm = get_my_size($_GET['width'], $_GET['length'],'2.99')+$size;