0

I have found in different web sites (for example here) this statement:

This PHP code prints a newline using 10 bytes:

echo "\n";

This PHP code prints a newline using 9 bytes:

echo "
";

This PHP code prints a newline using 8 bytes (using the bitwise NOT operator ~):

echo ~õ;

My problem is that I can't make that last solution work in any possible way, test and environment that I used. I have tested on online PHP sandboxes, on local machine, etc, when I execute

echo ~õ;

I get always this output:

<J

Why? Can someone explain why I get this output and why it should print a newline?

Mario
  • 420
  • 1
  • 11
  • 23
  • Don't use stuff from your example side above. Thats allover bad practise what he explains there and makes code unreadable e.g. `$c%4?$q+=print$a:0;` . Write a new-line in a normal way. Don't use this wired stuff `~õ`. – Foobar Dec 21 '22 at 11:24
  • 1
    Whatever if you want to reproduce, keep this in mind (from the webside): _Make sure to set your text editor to latin1 (ISO-8859-1 or Windows-1252) instead of UTF8 otherwise you will save those inverted bytes as multi-bytes which will do the opposite of what we are trying to do here._ – Foobar Dec 21 '22 at 11:36
  • @Foobar Yes, usually I write well formatted readable code, but in this particular case the goal is to write the program with less possible bytes, so saving 1 or 2 bytes will help. I would never code like that in a production situation. – Mario Dec 21 '22 at 14:43

0 Answers0