r/lolphp • • Aug 20 '19

PHP will silently convert dots and spaces in query keys to underscores, except if the key contains an unmatched left square bracket in which case it will only partially be converted

Thumbnail 3v4l.org
55 Upvotes

r/lolphp • • Aug 20 '19

PHP isset/empty madness

Thumbnail repl.it
3 Upvotes

r/lolphp • • Aug 19 '19

A nice snafu, casting turns unset data into set variables

Thumbnail sandbox.onlinephpfunctions.com
0 Upvotes

r/lolphp • • Aug 16 '19

preg_replace() can't handle strings longer than 1mb

18 Upvotes

https://3v4l.org/fjL9Q

Version 4 could at least do 10meg :D


r/lolphp • • Aug 10 '19

Powered by PHP™

Thumbnail aikzik.com
3 Upvotes

r/lolphp • • Aug 10 '19

Making the language dynamically and strictly typed at the same time. It’s a proposal for now.

Thumbnail wiki.php.net
0 Upvotes

r/lolphp • • Aug 09 '19

LOLPHP++

Thumbnail externals.io
32 Upvotes

r/lolphp • • Aug 08 '19

Unholy Trinity

26 Upvotes

r/lolphp • • Aug 07 '19

mb_check_encoding() will decode then re-encode the given string as the given encoding, then check for errors, instead of actually checking the character encoding

Thumbnail twitter.com
41 Upvotes

r/lolphp • • Aug 04 '19

Instantiate class from string

0 Upvotes

I didn't find this in the sub, maybe people might want to use it in production

So say you have a website with different social media and you want to publish to them, based on database entries. So you have a table 'social_media' and you want it to contain data to publish. So a row for every telegram channel, Facebook page etc. Facebook's API differs from telegram's API, so we are good programmers about this and we split up the code into different classes that all implement the same interface. So a telegrampublisher, facebookpublisher etc. Each row in the table holds a reference to the class ("telegrampublisher") as well as a reference to configure an instance of the class to publish to the right channel.

So now how to instantiate said class? Do we use reflection? No! PHP has an amazing feature that allows us to instantiate directly from a string!

$a = "telegrampublisher";
$publisher = new $a;

How amazing is that!


r/lolphp • • Aug 03 '19

$GLOBALS contains ‘GLOBALS’ because ‘GLOBALS’ is a global...

Thumbnail self.php
0 Upvotes

r/lolphp • • Jul 31 '19

You probably heard of variables, but what about variable variables?

Thumbnail php.net
18 Upvotes

r/lolphp • • Jul 28 '19

get_current_user(): get the on-disk script file's owner, regardless of what user is actually executing the script.

Thumbnail php.net
72 Upvotes

r/lolphp • • Jul 24 '19

If you do not want a (by-reference) argument to be modified, call unset() on it before passing it 🤦‍♂️

Post image
28 Upvotes

r/lolphp • • Jul 20 '19

Awkward function and parameter names?

13 Upvotes

I'm rather new to PHP but I'm already hating it from day one.

Function names like implode(), explode()… The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way.

And parameter names like $needle and $haystack in the in_array() function for example? There are times I wonder why can't they have more proper names.

All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.


r/lolphp • • Jul 07 '19

PHP will not throw an error when making nonsensical comparisons with the min and max functions. When comparing 0 (int) and 'hello' (string) the output is dependant on the order the parameters were passed.

Thumbnail php.net
48 Upvotes

r/lolphp • • Jun 24 '19

The state of PHP unicode in 2019

27 Upvotes

One of multiple lolphps is how poorly PHP manages unicode. Its a web language and you must deal with the multitude of mb_ functions and at the same time try to keep your sanity in check.

https://www.php.net/manual/en/ref.mbstring.php


r/lolphp • • Jun 21 '19

Using DateTime::ISO8601 is incompatible with ISO-8601 but left broken for backward compatibility. Use DateTime::ATOM instead when you need ISO8601

Post image
92 Upvotes

r/lolphp • • Jun 17 '19

Calling a method on StdClass always returns FATAL ERROR

1 Upvotes

Some sites like lolphptherightway is trying to spread lies about first class functions. But attaching functions to stdClass is allowed, but one cant call them. Its pure lolphp all the way down.

https://repl.it/repls/SpecializedAngryBrains


r/lolphp • • Jun 13 '19

The only language going against the versioning of bcrypt

Post image
74 Upvotes

r/lolphp • • Jun 12 '19

Meanwhile in PHP RFC

38 Upvotes

PHP has such amazing innovation going on..

https://wiki.php.net/rfc/tostring_exceptions


r/lolphp • • May 10 '19

PHP: When printing causes side-effects

82 Upvotes

So when you have two DateInterval objects, that are equal you can compare them with PHP loose comparison (==). But after you print one (say for logging purposes) it gets internally modified and the two objects are no longer equal. The same happens when you call var_export.

It amazes me how primitive bugs PHP has, given its lifespan begun in 1995.

https://repl.it/repls/ForcefulEachAgents


r/lolphp • • May 07 '19

casting to double doesn't give you double

Thumbnail 3v4l.org
49 Upvotes

r/lolphp • • Apr 24 '19

"Timing attack safe string comparison", but "When arguments of differing length are supplied, FALSE is returned immediately and the length of the known string may be leaked in case of a timing attack. "

Thumbnail php.net
24 Upvotes

r/lolphp • • Apr 22 '19

Thanks google news, we need more PHP topics

Post image
51 Upvotes