0

I am getting a Parse error: syntax error, unexpected '–' (T_STRING) in the following line:

$lbm = ((0.407 * $weightkg) + (0.267  * $heightcm) - 19.2) / 0.453592;

From what I see, I am using a subtraction sign and not a hyphen. Other than that, I don't know what could be wrong. Anyone know how to fix this?

  • Try: Delete the - and type in a - from the keyboard. The error does not look related to that code. Have a test case snippet link from an online REPL? – user2864740 May 02 '20 at 06:40

1 Answers1

2

Well, the character you pasted into the title is definitely an en-dash rather than a minus symbol(a) so PHP is rightly complaining about it.

The line in the main body of your question is a hyphen so either you've typed in in differently or that's not the line where the error is (PHP can sometimes be a bit iffy as to where it reports errors, so you may want to look on the few lines immediately around the one it reports the error to be on).


(a) Which is actually distinct from a hyphen, at least in typography, so you may want to beware of lunatic typographers coming around to beat you up for your transgressions :-)

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953