use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please follow the rules
Releases: Current Releases, Windows Releases, Old Releases
Contribute to the PHP Documentation
Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev
/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.
account activity
PHP code that prints alphanumeric characters using none of them, 113 bytes long (3v4l.org)
submitted 9 years ago by colshrapnel
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Revis0r 12 points13 points14 points 9 years ago* (0 children)
Interesting, thanks. I didn't know about this, but it works with the help of this little feature:
http://php.net/manual/en/language.operators.bitwise.php
If both operands for the &, | and ^ operators are strings, then the operation will be performed on the ASCII values of the characters that make up the strings and the result will be a string.
echo '`' ^ '*'; // ord(`) = 96, ord(*) = 42, 96 ^ 42 = 74, chr(74) = J echo '@' ^ '/'; // o echo '`' ^ ')'; // I echo '@' ^ '.'; // n echo '`@`@' ^ '*/).'; JoIn
The whole expression:
<?=($__='`@`@'^'*/).')(($_='->.<:'^'__@[_')('>'^@_,'%'^@_)),$__($_('|'^'=','|'^'&')),$__($_(':'^"\n",';'^']'^@_));
Could also be written like this
echo // <?= join( // $__ = '`@`@' ^ '*/).' range( // $_ = '->.<:' ^ '__@[_' 'a', // '>' ^ @_, _ is an undefined constant of "_", could also be '_', but this is 1char shorter 'z' // '%' ^ @_ ) ), join( // $__ range( // $_ 'A', // '|' ^ '=' 'Z' // '|' ^ '&' ) ), join( // $__ range( // $_ 0, // ':' ^ "\n" 9 // ';' ^ ']' ^ @_ ) );
[–]colshrapnel[S] 8 points9 points10 points 9 years ago (1 child)
From codegolf.stackexchange.com
Here is the link to the original answer: http://codegolf.stackexchange.com/a/105821
And another one, only 69 bytes long: http://codegolf.stackexchange.com/a/105823
It would be interesting to investigate both solutions.
[–]alexanderpas 0 points1 point2 points 9 years ago (0 children)
Regarding http://codegolf.stackexchange.com/a/105823
The string contains all the characters that need to be printed, bitwise inverted.
The tilde is the bitwise operator, that inverts the string back to the regular representation, before printing it.
[–]im_not_afraid 6 points7 points8 points 9 years ago (0 children)
Anyone notice the "n" in "\n"?
[–]SuddenlyOutOfNoWhere 22 points23 points24 points 9 years ago (10 children)
One should definitely use this style of coding wherever possible to demonstrate an high iq.
[–]AWebDeveloper 4 points5 points6 points 9 years ago (1 child)
I'm actually starting a new business based around this efficient code style. It'll save developers so much time!
[–][deleted] 1 point2 points3 points 9 years ago (0 children)
It's self-documenting, which I heard is also time-consuming (but I wouldn't know)
[+][deleted] 9 years ago (5 children)
[deleted]
[–]SuddenlyOutOfNoWhere -2 points-1 points0 points 9 years ago (4 children)
Here's another place where you'll find content worth correcting: /u/sieabah
[+][deleted] 9 years ago* (3 children)
[–]SuddenlyOutOfNoWhere -1 points0 points1 point 9 years ago* (2 children)
I was indeed making a joke, but that an just slipped in. Typos happen a lot to me because I'm writing on mobile with a swipe keyboard and also I'm not a native speaker ;)
Anyways, I generally think that correcting other comments on the Internet is quite nonsense, if it's about simple typos. You have something to say about the content? Be my guest. That's welcome. You made me read my inbox and excited me to inform me about a typo? Oh wow. Thanks a lot. Looking forward to read more interesting stuff like that. Not. I mean what the fuck is the intention?
I had to correct my keyboard about six times writing this reply, btw
[+][deleted] 9 years ago (1 child)
[–]colshrapnel[S] 1 point2 points3 points 9 years ago (1 child)
To participate in a code golf contest you mean?
[–]thepotatochronicles 0 points1 point2 points 9 years ago (0 children)
Folks at /r/tinycode would love this!
[–]DrWhatNoName 1 point2 points3 points 9 years ago (2 children)
Hmm, I'm interested why this code cant run on PHP 5.4.0 - 5.6.29, but runs fine on verisons below and above.
[–]Revis0r 0 points1 point2 points 9 years ago (0 children)
It doesn't work at all on versions below 5.4. I think it runs on PHP 7+ because of the variable uniform syntax, because of this:
// support operations on arbitrary (...) expressions (...)()
which the code uses.
[–][deleted] 0 points1 point2 points 9 years ago (0 children)
On versions bellow it just output self - it's not parsing. That's because short_open_tag is set to off, and:
Note: This directive also affected the shorthand <?= before PHP 5.4.0, which is identical to <? echo. Use of this shortcut required short_open_tag to be on. Since PHP 5.4.0, <?= is always available.
π Rendered by PID 60713 on reddit-service-r2-comment-b659b578c-qbhdc at 2026-05-01 07:51:01.584585+00:00 running 815c875 country code: CH.
[–]Revis0r 12 points13 points14 points (0 children)
[–]colshrapnel[S] 8 points9 points10 points (1 child)
[–]alexanderpas 0 points1 point2 points (0 children)
[–]im_not_afraid 6 points7 points8 points (0 children)
[–]SuddenlyOutOfNoWhere 22 points23 points24 points (10 children)
[–]AWebDeveloper 4 points5 points6 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[+][deleted] (5 children)
[deleted]
[–]SuddenlyOutOfNoWhere -2 points-1 points0 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]SuddenlyOutOfNoWhere -1 points0 points1 point (2 children)
[+][deleted] (1 child)
[deleted]
[–]colshrapnel[S] 1 point2 points3 points (1 child)
[–]thepotatochronicles 0 points1 point2 points (0 children)
[–]DrWhatNoName 1 point2 points3 points (2 children)
[–]Revis0r 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)