-3

I come across following sentence in PHP Manual

As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in \{$var} had not been printed.

I want the examples of string with backslashes in PHP version before 5.1.1 and in PHP version 7.2.6 which demonstrates that before PHP 5.1.1, the backslash in \{$var} had not been printed and now it's been printed in PHP 7.2.6.

PHPLover
  • 1
  • 51
  • 158
  • 311
  • 2
    Which part are you having issues with? You can test different versions of PHP using: https://3v4l.org/Ss12Y – JustBaron Jun 25 '18 at 07:55

1 Answers1

-1
<?php
$var = 'x';
var_dump("foo \" bar \{$var} foo");

Output for 5.1.1 - 5.6.30, hhvm-3.10.1 - 3.22.0, 7.0.0 - 7.3.0alpha1

string(18) "foo " bar \{x} foo"

Output for 5.1.0

string(20) "foo " bar {$var} foo"

Output for 4.3.0 - 5.0.5

string(17) "foo " bar {x} foo"

steros
  • 1,794
  • 2
  • 26
  • 60
  • I believe the DV came because of the lack of exaplantion on this, though it does help the OP, this is on the internet forever, someone is going to find this and find it of no use as you don't say why this works / how. This is likely the reason for DV – Can O' Spam Jun 26 '18 at 11:05
  • I think that it was just a misunderstanding that the documentation was mentioning `\{$var}` literally. – steros Jun 26 '18 at 11:19
  • Yes - but you fail to add any explanation of to what this does, why it exists, you and I know, but do people who have only just started and never seen it before? A high quality answer is important, and currently, this is not even low quality, I feel like I've put more effort into comments than the answer took to write, I myself DV'd this for that very reason, add explanation of what & why this is, and I'll happily retract it – Can O' Spam Jun 26 '18 at 11:21
  • 1
    I see. I tried to answer his question as precise as possible. Which was to give him an example of the case. I can add more information if I find the time. – steros Jun 26 '18 at 11:26
  • @steros : Your example helped me a lot in understanding the change in execution from one version of PHP to another. I've already accepted your answer. If possible please provide some explanation to your answer because without the explanation your answer would be useful only for me and not for the PHP community. Thank You. – PHPLover Jul 07 '18 at 05:01