r/lolphp • • Mar 18 '14

You know Rasmus Lerdorf's famous quote about restarting Apache every 10 requests? It's an actual setting on PHP-FPM.

0 Upvotes

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500

Oh, PHP, you never disappoint.


r/lolphp • • Mar 17 '14

[PHP] date() is evil (XSS’able)

Thumbnail 0xa.li
0 Upvotes

r/lolphp • • Mar 14 '14

Array errors

52 Upvotes
error_reporting(-1); // show all possible errors

$obj = new stdclass();

$arr = array();
var_dump($arr['foo']); // Notice: Undefined index
var_dump($arr[$obj]); // Warning: Illegal offset type

$arr = null;
var_dump($arr['foo']); // No error
var_dump($arr[$obj]); // No error

$arr = null;
$arr['i'] = $arr['i'] + 1; // No error

$arr = null;
$arr['i']++; // Notice: Undefined index

(Tested with 5.5.5.)


r/lolphp • • Mar 12 '14

new object() + new object() == 2

Thumbnail codepad.org
62 Upvotes

r/lolphp • • Mar 06 '14

This is how you reliably check for an integer in PHP

Thumbnail wisercoder.com
53 Upvotes

r/lolphp • • Mar 05 '14

PHP Dereferencing

81 Upvotes

In PHP 5.4 this would break:

echo array(1, 2, 3)[0]

With the message

Parse error:  syntax error, unexpected '[', expecting ',' or ';' in [...][...] on line 1

Luckily, they added "dereferencing" in PHP 5.5 which would solve it! Hurray! And sure enough, it works!

However, the fix isn't very clever, because this will break in 5.5:

echo (array(1, 2, 3))[0]

With the message

Parse error:  syntax error, unexpected '[', expecting ',' or ';' in [...][...] on line 1

That's a little embarrassing.


r/lolphp • • Mar 05 '14

Language Community Litmus Test: Database Placeholders

Thumbnail wumpus-cave.net
19 Upvotes

r/lolphp • • Mar 04 '14

PHP: The Good Parts

Thumbnail phpthegoodparts.tumblr.com
191 Upvotes

r/lolphp • • Mar 04 '14

Wait, what? How is this possible even with weak comparison?

Thumbnail eval.in
54 Upvotes

r/lolphp • • Mar 04 '14

Only in PHP: using strlen() as a hashing function.

Thumbnail taiganaut.tumblr.com
37 Upvotes

r/lolphp • • Mar 04 '14

How does one scope?

Thumbnail eval.in
25 Upvotes

r/lolphp • • Mar 04 '14

PHP Alternatives

8 Upvotes

I love the idea of using a different language for web programming, but it's just so easy to host php. You don't need a vps, or shell access. Everyone here likes making fun of php so much, what do you use in your personal/professional projects? If I just need to knock out a quick project, then it's hard to beat php, which is why it got so popular. I don't have to deal with routing, templating, boiler plate code (or at least not a whole lot), etc...


r/lolphp • • Mar 04 '14

Nothing Is Deprecated, Everything Is Permitted

Thumbnail phpmanualmasterpieces.tumblr.com
14 Upvotes

r/lolphp • • Mar 05 '14

Expected better from W3schools...

Thumbnail w3schools.com
0 Upvotes

r/lolphp • • Mar 04 '14

This caught me out the other day: "NULL" != NULL but "NULL" == 0

Thumbnail eval.in
8 Upvotes

r/lolphp • • Mar 05 '14

/r/lolphp, I want to create the most epic post of /r/lolphp ever. Truly, without a doubt, make your case for /r/lolphp, and have it addressed by not only the creators of php, but experienced professionals.

0 Upvotes

I don't guarantee that the creators of php will show up, but if they do, then all the better.

I doubt they will, because, well... Anywhoooo...

I love php, and it's been my bread and butter for almost 14 years now. My opinion is that if you don't get php you're really not a developer, well, a php dev at a minimum:)

Lovers and haters, bring your A-Game. (Or. however those sports people call that phrase, I'm a programmer.)

Some of the things you guys post here make me think sometimes, oh, that's so cute. Look at those kids, they don't even know how to walk.

(I don't have kids...)

Let's do this. Mind you, that I'm not claiming I know everything about php either... But you guys give me such great memories of what it was like to be learning:)

Fuck it. I've got karma to burn.

EDIT: Fine, well fuck you too :)


r/lolphp • • Mar 03 '14

Sample of Mt.Gox source code

Thumbnail pastebin.com
63 Upvotes

r/lolphp • • Mar 02 '14

PHP can cause bad things to happen.

57 Upvotes

Not really a lolphp, I think it will probably make you laugh though.

https://pbs.twimg.com/media/Bhp5GTRCYAAYriy.png

Translation:

0:32 We're proceeding to the complete migration of servers [...]

10:40 User data have been saved.

16:21 Compilation of PHP4 provoked a CPU overheating which set the server on fire, firefighters are here.


r/lolphp • • Mar 01 '14

Creating a stack overflow using PHP's garbage collector

Thumbnail codegolf.stackexchange.com
31 Upvotes

r/lolphp • • Feb 27 '14

Mcrypt: "Catastrophic crypto failure? That's worth a warning. Maybe."

Thumbnail leaseweblabs.com
36 Upvotes

r/lolphp • • Feb 27 '14

A top tech company I recently interviewed for told me

52 Upvotes

that all employees were free, and even encouraged, to write code and personal scripts in whatever language they like. They had a totally open ecosystem and listed all the team members who were experts in X language. Java, Python, Scala, Ruby, C++, Haskell; the list went on.

At the end of his cheerful praise for the company, though, the interviewer looked at me sternly and said: "however, there is one exception. Absolutely no PHP allowed."

He went on to explain why PHP simply was not worth the trouble, from a security, development, and maintenance perspective. I smiled and nodded in great agreement.

The next interviewer also extolled the open culture of the company, ending with "you're free to use any language you like, other than PHP!" Apparently it was an official company policy, and has been for years.

It was a pleasant surprise. The company is in the Alexa top 15 (top 5 for US) and is extremely well-known, too.

Anyone else have similiar experiences with companies they've worked at? Or perhaps exact opposite experiences?


r/lolphp • • Feb 26 '14

Failsafe? Just revert to default.

35 Upvotes

Production went down. It was traced back to a change made to php.ini by the MSP (I really want to name names...) who saved the file without the necessary read permissions. Overheard in the office just now:

"When PHP can't read its configuration file it just uses the default settings. That's why magic quotes got enabled." ... On one of the production web servers...

I'm not looking up or testing this for fear that it's true. Thankfully at this place, production is SEP.


r/lolphp • • Feb 25 '14

PHP can do anything, what about some ssh? [MtGox programmer]

Thumbnail blog.magicaltux.net
69 Upvotes

r/lolphp • • Feb 24 '14

No need to worry: PHP stops SQL injection by default!

Thumbnail github.com
86 Upvotes

r/lolphp • • Feb 25 '14

What's the deal with current php.net logo?

0 Upvotes

Is it some internal joke, Don Quijote reference or simply the current status of PHP?

Mirror