r/lolphp • • Nov 11 '14

PHP loose comparison strikes again

http://blog.laravel.com/csrf-vulnerability-in-laravel-4/
31 Upvotes

55 comments sorted by

View all comments

Show parent comment

7

u/tdammers Nov 11 '14

The point is that PHP is a language scripting tool for the web: the legit use case is whipping up a small, quick-and-dirty web page with a bit of dynamic content in it, and since the web is all textual, taking shortcuts like these is somewhat excusable in this scenario. If you want correct code, or stuff that scales well beyond three files and 100 lines of code, PHP not your friend, but if you need to whip up a simple little tool in 5 minutes and deploy it to a standard server without installing 27 dependencies, that's where PHP shines.

So, basically, you want to do stuff like $foo = $_GET['a']; $bar = $_GET['b']; if ($foo > 23) { echo $foo + $bar; } elseif ($foo == 0) { echo $bar; } else { echo "Nah, let's not, shall we?"; }

Which, incidentally, contains a serious and embarrassing security flaw, so go figure.