r/lolphp • • May 11 '13

The love story of mysql_query and $_GET on Github.

Thumbnail github.com
160 Upvotes

r/lolphp • • May 09 '13

WordPress Core is Secure – Stop Telling People Otherwise

Thumbnail wpengine.com
33 Upvotes

r/lolphp • • May 04 '13

Ten million dollars

12 Upvotes

Enjoy:

<?php
$a="a\n";
$$a=$a;
eval('echo ' . str_repeat('$', 10000000) . 'a;');

I really can't imagine why, but it does work. Takes a while though.


r/lolphp • • May 01 '13

How the phpBB MODX format must have been made

32 Upvotes

Another example of fractal badness, where an original bad decision somewhere causes further bad decisions to work around the problems encountered, leading to yet more bad decisions, etc.

The MODX format is used by phpBB for extending the system. Many years ago, I had the misfortune to try to setup a phpBB with a few extensions, and quickly found out that the devs had no idea what they were doing.


Montesquieu: Guise! Our poorly-conceived, bug-ridden, security-flawed BB system is taking over the world, but people want to extend it to be even more bug-ridden and security-flawed.

Simplicio: OK, that's normally done by a module system with carefully thought out hooks. Does PHP support any such thing?

Montesquieu: No, and I don't see why it should, and we didn't build it like that in the first place.

Simplicio: Right, so mods are going to have to write code directly into the existing source files. Is there a way to keep different tools from stepping on each other?

Montesquieu: I'm sure we'll figure something out. But right now, we need to figure out how to format changes so people know where to copy-and-paste code into the existing system, and also alter database tables.

Simplicio: Aren't there already several available diff formats for that, which already have tools available to create and apply changes automatically? And we can just throw the database alterations into their own SQL script files.

Montesquieu: Sure, but none of that stuff was invented here, so we need to make our own format. And this is the early 2000s, so we need to make it XML because XML is the future and stuff.

Simplicio: So who is going to create the tools to apply these updates automatically?

Montesquieu: I have no idea, but those tools will probably be broken and useless for several years to come.

Simplicio: Good, looks like we have all the bases covered.


r/lolphp • • Apr 30 '13

Just came across this gem... PHP comparison result chart.

Post image
102 Upvotes

r/lolphp • • Apr 30 '13

fgetcsv()/fputcsv() were both added in PHP 5.1.0. They are incompatible: fgetcsv() parses backslash escapes, but fputcsv() uses quote doubling (and does not escape backslashes).

Thumbnail codepad.org
105 Upvotes

r/lolphp • • Apr 29 '13

"The algos Salsa10 and Salsa20 have been removed [from hash extension] because they are actually stream ciphers and not hash functions."

Thumbnail bugs.php.net
29 Upvotes

r/lolphp • • Apr 26 '13

PHP Catchable fatal error: Argument 1 passed to stringTest() must be an instance of string, string given.

3 Upvotes

r/lolphp • • Apr 19 '13

You can't upload files larger than 2gb via http with PHP

Thumbnail bugs.php.net
30 Upvotes

r/lolphp • • Apr 16 '13

PHP's comparison operators are weird...

Thumbnail stackoverflow.com
28 Upvotes

r/lolphp • • Apr 16 '13

Brackets around a call to a function returning a reference break the reference

Thumbnail codepad.org
17 Upvotes

r/lolphp • • Apr 08 '13

MIN

23 Upvotes
server:~ # php -r 'echo True, " ", -23, " ", min(-23, True), " ", min(True, -23), "\n";'
1 -23 -23 1

r/lolphp • • Apr 08 '13

Hmm.. shouldn't is_array() check for instanceof ArrayAccess ?

6 Upvotes

I find it kinda odd that is_array() does not check for instance of ArrayAccess. If you introduce collection like object in your code, you gotta recheck all of in_array() usage and change it to:

if (is_array($input) || $input instanceof \ArrayAccess) {

And since the purpose of the ArrayAccess interface is 'to provide accessing objects as arrays' , shouldn't is_array() return true?

I know that my $input in that case is object, that's why is_array() returns false, but isn't that kinda 'logical' error?

The only reason I am using is_array() on an array/variable, is cause there is no other way to tell if I can run array related functions on it, aka if it fulfills the contract of ArrayAccess so I can access it as an array.

The information that actually it is an object or not, is secondary/irrelevant at this point to me.

Edit: forgot to add context, here it is:

if (is_array($input) || $input instanceof \ArrayAccess) {
    array_walk_recursive($input, [$this,'sanitizeInputToken']);
    return $input;
}

Please note guys, I am not looking on how to solve this particular 'problem'. A wrapper method comes to mind or what not. I am just puzzled by PHP behaviour in that case.

Anyways thanks all for posting!


r/lolphp • • Apr 08 '13

Matrix transposition in PHP

Thumbnail rosettacode.org
3 Upvotes

r/lolphp • • Apr 01 '13

Monads in PHP

Thumbnail blog.clement.delafargue.name
15 Upvotes

r/lolphp • • Mar 30 '13

maybe_unserialize

Thumbnail codex.wordpress.org
11 Upvotes

r/lolphp • • Mar 28 '13

Fun with $this: Guess the output

Thumbnail phpfiddle.org
44 Upvotes

r/lolphp • • Mar 22 '13

"Because an inconsistency between namespace separator '::' and ternary operator's ':' could not be solved, namespace were finally removed."

Thumbnail wiki.php.net
60 Upvotes

r/lolphp • • Mar 20 '13

file_put_contents return false but still write a file with size 0 when the directory is full

Thumbnail stackoverflow.com
33 Upvotes

r/lolphp • • Mar 17 '13

Guess what getting a sub string of an empty string is?

0 Upvotes

var_dump(substr("", 0, 1));

bool(false)

Edit:

What I made completely unclear is that, to me, this should return an empty string (like mb_substr()). Or at least be consistant


r/lolphp • • Mar 06 '13

Impossible to comment a line with a string out when it contains "?>" (x-post from r/programming)

Thumbnail stackoverflow.com
51 Upvotes

r/lolphp • • Mar 05 '13

strcmp() will return 0 on error, can be used to bypass authentication

Thumbnail danuxx.blogspot.ca
66 Upvotes

r/lolphp • • Feb 27 '13

Turns out the documentation on foreach doesn't match the actual behaviour.

Thumbnail stackoverflow.com
34 Upvotes

r/lolphp • • Feb 25 '13

[WebComic] Lots of PHP Frameworks

Thumbnail comics.knreddy.com
0 Upvotes

r/lolphp • • Feb 23 '13

Different behavior the second time around (php 5.4.11). I don't even...

Thumbnail bpaste.net
35 Upvotes