Jump to content

charlie321

Members
  • Posts

    59
  • Joined

  • Last visited

Everything posted by charlie321

  1. I have posted a modified function above already. Please reference that. Below is the code that woks fine as a non- function: if ($state == "FL") { $stax = ($subtotal-$credit+$shipping) * .07; } As I have said, this works but is redundant as it is presented several times throughout the code. Thus my wanting to make it a function.
  2. I had taken the FL if statement out to see if that was the problem. But did not work that way either. This works fine in code. Basically am trying to get the result as sales tax for the state of Florida using subtotal of invoice, credit, and shipping totals. Something within the function is preventing that from happening as it never gives anything but 0 for sales tax variable ($stax) As I said it works fine in code. I believe it is something to do with the variables not passing into or out of the function. I have worked with functions in other languages with no problems passing variables. Has to be something I am missing.
  3. I tried this which I thought might be what you were getting at but no success. More help please. function tax_invoice($subtotal,$credit,$shipping,$state) { if ($state == "FL") { $stax = ($subtotal-$credit+$shipping) * .07; return $stax; } }
  4. Trying to understand php functions. function tax_invoice() { if ($state == "FL") { $stax = ($subtotal-$credit+$shipping) * .07; } } #call function: tax_invoice(); I have tried different variations including in script, on own functions program, using return, adding variables, etc. Nothing seems to work unless I use it as a non-function in code. Please help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.