This tutorial is using the same base code as Add two numbers, but with using the function addtwo, this takes two parameters $a and $b which are both set to 0 as the default value and returns the two values added together. The answer part of the web page uses the function to add the two numbers together.
The source code
PHP - Add two numbers
Answer :
save as addtwonumbers_function.php, this program will function the same as the previous tutorial apart from the inner working will call the method. The method programming allows for one method to be called multiple times, e.g. Within the example above there could be a method that was 5 lines in length and instead of writing the same 5 lines each time, you just write a method that is called.
Shouldn’t the method be called with a comma between the arguments rather than an operand?
Well spotted Tom, I copy and pasted from the previous tutorial and forgot to alter the parameters to the function.. It was
Answer :
$value1 = $_POST[‘value1’];
$value2 = $_POST[‘value2’];
Errors:
Notice: Undefined index: value1 in D:\PHP\EasyPHP 3.0\www\test.php on line 14
Notice: Undefined index: value2 in D:\PHP\EasyPHP 3.0\www\test.php on line 15
Did you place the full html code from above ? because the $_POST means values from the