I am currently studying PHP4. I am aware that it is a little old and there is PHP5 out, if not PHP6 already. But, its currently the only manual I have and I want to break into it as easily as possible. My theory is once I start studyin PHP5, then it will be a walk in the park.
This was taken straight out of the manual I am studying from.
Returning Values from User-Defined Functions:
Listing 6.4 creates a function that returns the sum of two numbers.
Listing 6.4: A Function That Returns a Value
3: <title>Listing 6.4</title>
7: function addNums( $firstnum, $secondnum;
9: $result = $firstnum + $secondnum )
10: return $result;11: }
12: print addNums(3,5);
13: // will print "8"
Once I copied it into Dreamweaver 8, I came up with some errors.
So, I modified the script due to what looked like some missing brackets and a number 11 which made no sense and a few other things. This is what I came up with.
7: function addNums( $firstnum, $secondnum )
9: $result = $firstnum + $secondnum;
10: return( $result );
12: print addNums(3,5); // will print "8"
Am I correct? If so, what were the errors in the example from the book?