ok, im planning on using functions from now on but i have one question
ok here goes.... this is completely made up and i have no use for it
say i have this
$var + 13 + 6 = $answer;
$answer / $var = $finalanswer
say i created that as a function but then..........
i needed to changed it to
$var + 13333 + 6 = $answer;
$answer / $var = $finalanswer
would i have to create a whole new function or could i do something to the old one?
Cheers,
an intrigued coder
recyclable functions
Moderator: General Moderators
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
Code: Select all
<?php
function some_math ($first, $second = 13) { // if you don't set $second as something (some_math (1)), it would automaticly be set as 13.
$answer = $first + $second + 6;
$final_answer = $answer / $var;
return $final_answer;
}
?>-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
Or:vigge89 wrote:Code: Select all
<?php function some_math ($first, $second = 13) { // if you don't set $second as something (some_math (1)), it would automaticly be set as 13. $answer = $first + $second + 6; $final_answer = $answer / $var; return $final_answer; } ?>
Code: Select all
function calculation_1($a, $b, $c, $d)
{
return ($a + $b + $c) / $d;
}Code: Select all
// add value added tax to the pre vat price
function getTotalPrice($price_ex_vat)
{
return $price_ex_vat * (1 + VAT_RATE);
}