I think mine would be
json_encode(). I think it's so cool that a single function can make your data understood by other machines. (I know other machines can interpret different kinds of data, but c'mon...)
How about you? What's your favourite function?
Top comments (36)
Based on usage it's probably
var_dump (); die ()!!!
I usually do like:
I stopped doing this simply because I can't do it if I dump multiple variables at once.
But you could do
die(var_dump($res, $res2));, couldn't you?
Really? Wow, #TIL!
Yeah, just like
console.log(var1, var2)in JS
random()functions, there is so much more behind them then we usually think. I can talk hours about entropy and sources, techniques, pseudo algorithms and how can it improve almost any software product.
Improve in what way?
As in, some product features can be improved using random (shuffle or generate things), most basic example is chose new 5 news headlines to see from the top 100 articles to an user, each x seconds/page views.
p e r s o n a l i z a t i o n
In the way of randomized algorithms
In PHP I always include file with my custom helper functions. These two wrap output with
<pre/>tags, which allows nice&quick debugging via browser from any class or template code.
HA! I have a pre() function too! I use it many, many times a day. Mine has the $obj, but then a title, so if I have multiple pre()s going, I know which is which. Like, pre( $obj, 'This is the user obj');
var_masterpiece is also an excellent browser extension too for debugging!
Because it took me almost half a year to realize that it's a function, not a language construct.
beforeAlls, etc in Jasmine tests without actually caring about the legit expectations yet.
Arrow function 🤓.
thishas never been easier.
In Ruby, backticks are a function call. And what's especially cool is that heredocuments with backticks call the same function, but with multi line arguments. So you can define them to do other, more interesting things, like call out to other languages! In practice, I mostly use it when experimenting with some slightly tedious external resource, I basically learned PostgreSQL by running them through these kinds of functions.
curryfunction is probably my prefered one.
For those who don't know its utility, here's a basic example:
I even made my own optimized version 😄
I don't know why but I just love
sprintf()in php ... It's very useful and much more elegant than just endlessly concatenate strings !
And less elegant but really useful once again,
die(var_dump())has a special place in my heart ...
map, filter, reduce, forEach, Array.prototype.some, Array.prototype.every
Love it all!
Agreed, high order functions are best
Love throwing exceptions around ;)