1

The following code

$t =   1 – (1 - 2);

yields:

Parse error: syntax error, unexpected T_STRING on line 3 in php 5.2.3 and in 5.4 I get Parse error: in <file> on line 3

To me it seems like I'm subtracting one expression from another, which I would imagine is legal. Why is this a parse error?

2
  • 2
    That's the exact code and nothing else?
    – j08691
    Commented May 8, 2012 at 23:00
  • the expression before is closed with a semicolon?
    – dan-lee
    Commented May 8, 2012 at 23:03

1 Answer 1

8

The first "–" is an en-dash, but it should be a hyphen-minus like the latter one: "-". Replace it, and your code will work.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.