Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PHP is awesome

Name: Anonymous 2007-08-28 17:56 ID:xY3vpdBA

This is how you create a anonymous function in PHP:

$newfunc = create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');


Name: Anonymous 2007-08-30 17:48 ID:Xqzm1rko

>>40-41
Because PHP does not have true anonymous or first-class functions you fuckface! Of course JavaScript can do it, but JavaScript is conceptually better than PHP in a lot of ways and does actually support functional programming. There's no excuse other than sucking. I'm not defending PHP, I'm just posting what I do to make my life better doing PHP. (At least I can pretend I'm doing something that resembles FP, have dynamic typing and built-in lists and dictionaries; it would be much, much worse with Java.)

create_function() just blindly calls eval on code passed into it. Oops!
So? You're not going to do create_function('$x', $_REQUEST['lol']), are you? You know what create_function is for, don't do anything crazy. Also, eval is SNAFU, but for other reason (that return insanity).

>>42
Yes, that's why you do what I said in >>16 to at least support it. I found that by accident as I was doing exactly that, so I cursed the guys who did PHP, and worked around it.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List