(no subject)
red, pi
this fucking function is an example of why people who cannot tell the difference between an array and a hash-table should be shot in the nuts.

Why would you ever want to take the fucking keys of a numerically-indexed array? This function is indistinguishable, on some random array, from "give me n random numbers between 0 and some other number", with 'n' defaulting to 1.

The sad thing is that nobody in the comments page seems to have picked up on this. Instead, the most recent comment starts off talking about unset and goes on to paste a chunk of code that uses the same variable name ("parola") as some two-liner function that was originally posted in 200fucking7 and was hacked on by some third dude in '09.

I mean, on a hash, the function does something vaguely sensible (array_rand is not the most sensible name for a function that says "give me n random keys", but hey). This is why they are different structures, which can have different operations applied to them!

Of course, what am I to expect from a language whose "lambda" operation is a function on two strings that returns a string?

From Reddit: Variable variables
A bare word is a PHP string. Let that sink for a second, because we'll come back to it later: $foo really is the concatenation of $ the variable-indirection character (think *foo) and foo which is a string. foo === "foo" in PHP, even though in raw source code you'll probably get a warning. If those are enabled.
"I always said sanity was overrated."

(no subject)
programming languages
Zumwalt says "To replace his former PHP atrocity."
After*Image says "No other result is possible in PHP."
Zumwalt says "Heh. I see you have PHP experience."
After*Image says "Yes. It was extremely painful."
After*Image says "And that was before I tried to do functional programming (even though PHP lacks anonymous functions)."
Pi LAUGHS. A*I, check out what they added recently: http://www.php.net/create_function
After*Image says "Pi, that's not recent. And that's what I used. It's basically a glorified eval."
Zumwalt blinks. "It gives it a unique name? That's not anonymous, that's just broken."
Pi points at that. "Notice how it's not a closure and not an anonymous function? Yet they have the gall to call it 'similar to lambda'"
After*Image says "The problem is it creates new *named* functions. Unlike anonymous functions, they don't get garbage-collected."
Zumwalt says "Does PHP have any types other than string?"
After*Image says "And yeah, they're not closures."
Pi says "It's got bool, which decays to string irregularly."
Pi ohs. The PHP devs don't care about garbage collection -- they're of the mindset that gc happens on exit().
After*Image says "They have arrays which try to be both numerically indexed and associative."
Zumwalt says "Gah."
After*Image says "Not only does PHP have to keep compiling the function over and over in a loop (unlike Perl which does it once, having closures), each created function is a new object. I segfaulted apache before giving up."
Pi :/
After*Image says "Implementing stuff like compose() and bind() are even worse."
Pi mumbles some choice phrases about PHP
Pi says "I think the phrase 'limp-dicked shitpile' came up once."
After*Image says "The result of Create_Function() is a unique function name. It's guaranteed to be unique from anything you wrote because it has a NUL character in it, which you can't write because the parser barfs on NUL."
Zumwalt says "Your complaint about them not being garbage-collected...that wouldn't be a complaint unless some PHP scripts are long-running, am I right?"
Zumwalt says "But of course some are long-running."
After*Image says "Which means that you can't eval a code segment containing that function's name."
Pi whoas, A*I. I thought it was generated in a similar manner to (gentemp) in Lisp, ie introspect and increment a counter..
Zumwalt says "Gah!!"
Pi says "But that would be rational."
After*Image says "It does increment a counter. But it contains a NUL too."
Pi gags.
Zumwalt says "It would have to increment a counter, else you could only use it once."
After*Image says "So, to create a function which calls a created function, instead of generating a string of code which contains the created function's name, you have to substitute an expression which at runtime evaluates to the function's name."
Zumwalt can hardly wait to use his new Power Phrase: 'limp-dicked shitpile'
After*Image says "I've resolved not to ever install PHP (and therefore not to use any PHP apps) on any system I control."
Zumwalt reads more about create_function. "The comments are amusing."
Pi says "Yeah. A language whose documentation requires that users correct it on a live basis."
Zumwalt throws up a LOT in his mouth.
After*Image says "The PHP developer community is by itself sufficient reason to avoid it."
Zumwalt chortles at this comment: 'There is almost always an alternative solution to self modifying code.'
Zumwalt says "Gosh, takes me back to the 1970s!"
Pi is reminded of a quote: PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil, perpetrated by skilled but perverted professionals. - Jon Ribbens
After*Image says "It got better..."
Zumwalt says "'You can't refer to a class variable from an anonymous function inside a class method using $this. Anonymous functions don't inherit the method scope. You'll have to do this:' (horrible kluge follows)"
Zumwalt has to stop reading this comment thread in hopes of keeping his incipient dinner down.

After*Image says "I never actually worked with any PHP frameworks. Just the root of evil itself."
Zumwalt says "The Bible talks about building on sand."
After*Image says "Apt."
Pi says "PHP Shambleworks, more like."
After*Image says "Yeah, 'frame' is too solid-sounding for this purpose."

So I'm trying to weasel my way into this company, right? They asked me to do some minor PHP work for them. I thought it would be a straight-forward task. You know, simple form modifcation here, e-mail setup there. I'd only have to worry about learning a little bit of Joomla! and apparently ChronoForms. Right? It should be that simple, right?

No, of course not, because it's a fucking CMS written in fucking PHP. Once again I am convinced that the use of the eval() function by a given program is directly correlated with its quality.

So here's what went down: this guy wanted me to display the address information of a user through Joomla! and ChronoForms. JUser does not contain this information-- so I had to pull it from the database, then proceed to display it. But each row follows a format-- so to save code, I do this:
$tableformat = "<tr><td align='right'><b>%s:</b></td><td>%s</td></tr>\n";

At this point I also find out that if I want to pass the information I pulled down when the form is submitted and the data e-mailed to the administrator of the site, I have to pass them as fucking hidden form variables. This is where things get interesting.
$hiddenformat = "<input type='hidden' name='%s' value=\"%s\">\n";

So I'm feeling pretty good because I saved a ton of code space. A few executions of sprintf() later with the formats as the printing arguments, the code is properly formatted and I'm happy about things.

I try to set up the thing to e-mail clients but apparently can't seem to do that from my jurisdiction on the Joomla! control panel. So I talk to the guy who sets some stuff up. But out of fucking nowhere, a bug appears. It's a crippling syntax error.

I try changing the "form code" crap on the site to see if that isolates the error-- nope, it doesn't. I go to the "generated code" section to tweak some stuff there to no avail because you can't actually do that whatsoever. I try looking at every single possible thing from my jurisdiction until finally I ask the guy if I can get access to the Joomla! code, because there was no other way I was going to debug this.

While most people would blame the programmer in this situation, I don't. I don't blame the programmer at all-- I blame this fucking language. I blame this fucking language because it encourages you to throw shit at the wall to make it work. I blame this fucking language because it encourages bad coding habits and all sorts of nasty bullshit.

In order to run your form code with embedded PHP, it uses eval(). Which is fine I guess, but annoying. But after looking through the eval() code, it also looks for <input> tags. SO HEY. GUESS WHAT IT FUCKING PICKED UP ON AS AN INPUT VARIABLE?! THAT'S RIGHT:
$hiddenformat = "<input type='hidden' name='%s' value=\"%s\">\n";

So when I asked the guy to set up e-mail, he had to make a new table to associate with the form. When he did that, one of the columns was named %s. THE PROGRAM NAMED THE FUCKING COLUMN %s. This wouldn't be so big of a problem, really, if ChronoForms wasn't such a third-rate piece of shit Joomla! component.

Say you have a table that has the columns "foo", "bar" and "baz." When you associate this table with a form in ChronoForms, ChronoForms makes things """EASIER""" for you by adding procedurally generated code somewhere in the database that looks similar to this garbage:
if (!classexists("jos_chronoforms_MyBigFatGreekTable") {
class jos_chronoforms_MyBigFatGreekTable {
var $foo = null;
var $bar = null;
var $baz = null;

It then proceeds to later on eval() this fucking code. So when it generates the table, it basically makes a bunch of variable names in a class based on the column name. AND GUESS WHAT?? SOME CHARACTERS YOU JUST CAN'T HAVE IN A VARIABLE NAME, FOR EXAMPLE, %!! WOW SO GUESS WHAT HAPPENS WHEN YOU HAVE A VARIABLE NAMED $%s?!



So after manually dropping the fucking column and manually fixing the entry in the database that has that stupid fucking classexists function up there (THERE WAS PHP CODE STORED IN THE FUCKING DATABASE AUGH) the bug disappears. My form code then looks ugly as shit and is horribly inflexible because apparently being clever completely fucking breaks ChronoForms.

Thanks ChronoForms you did an amazing job at making things totally easier for me. You are a wonderful, brightly shining star in the world of PHP. Fuck you.

Oh hi there and welcome to FUCK PHP.

Here are some rules I think would be a Good Thing for you to follow:
  1. Don't be a dick. You are only allowed to be a dick if someone is being stupid.
  2. Don't be stupid.
  3. Formulate your rants coherently and make them entertaining!
  4. Please keep the defense of PHP at a minimum. There are some cool parts of PHP, and some parts of PHP don't deserve the hatred they get. But this is far and few between. Defend responsibly.
  5. I swear to god if you use this community as a launching point for your brand-spanking-new shiny CMS that has all these fancy bells and whistles I will fucking end you.

That should be about it I think! Be careful of Internet trolls and other un-savvy Internet personalities! They just might be here.


Log in