Home › Forums › Back End › Try out my first PHP web app! › Reply To: Try out my first PHP web app!
September 15, 2014 at 12:28 pm
#183141
__
Participant
Ok so if I do a return true at the end of the function, and then put it into use could I do something likeā¦
Yes.
A little confused in your Usage: section on why you passed $_POST into the function?
As a general rule, it is best to pass arguments you need into a function, rather than getting them from the global (or superglobal) scope. It makes it plain, just by looking at the function signature, what is needed for the function to work. It also means that you can be confident that you a working with the data you intended to work with. Some other, more practical benefits in this case:
- you can test your function by passing “dummy” input instead.
- you can accept form submission via other methods (e.g.,
GET
instead ofPOST
). - it is easier to do pre-processing (e.g., parse a JSON submission) on the input.