1

So, why in PHP, does the following code, print 'false'.

var_export('\'' === "\'");

Isn't it exactly the same?

Harm Smits
  • 437
  • 3
  • 10
  • 1
    If you `var_dump('\'');` you get `"'"`, with `var_dump("\'");` you get `"\'"` – Nigel Ren Jan 20 '21 at 08:39
  • @NigelRen Very weird hmm. – Harm Smits Jan 20 '21 at 08:40
  • No these are not same, if you do `var_export("\'");` with double quotes, this will return `'\\\''` but if you do with single quotes this outputs `'\''` with single quotes. – emppeak Jan 20 '21 at 08:42
  • [What is the difference between single-quoted and double-quoted strings in PHP?](https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php) – Definitely not Rafal Jan 20 '21 at 08:42
  • @emppeak I guess this has to do with how escaping might be slightly different for quoted / double quoted strings. Kinda weird if you ask me. – Harm Smits Jan 20 '21 at 09:03

0 Answers0