New features in PHP 7+

This post serves as a reminder, it is so easy to forget things nowadays. So here you go all in one list of PHP 7+ new features. Beware though, it is not 100% full, but 85-90% I think, I did omit some not-so-important features. I would be so glad if this article helped to save your time. Changes introduced in 7.0 Scalar type declarations An option to make PHP more stict on typing. We have the following types: ...

October 8, 2017 · 5 min · 988 words

Discovery of an advanced JOIN clause in MySQL

A little disclaimer: this is just a short self-initialized-probably-never-released postmortem note. Today at work I was silly enough not to ask help from my colleagues, I’ve decided to deal with the problem myself and came up with a shitty solution. During code review horrible hackery was revaled and I was taugh to live a simple life. Lets consider the following - there are two tables: SELECT * FROM docs | id | rev | content | |----|-----|---------------------------------------------------| | 1 | 1 | The earth is flat | | 2 | 1 | One hundred angels can dance on the head of a pin | SELECT * FROM docvalues | id | doc_id | property_id | value | |----|--------|-------------|--------| | 1 | 1 | 10 | First | | 2 | 1 | 10 | Second | | 3 | 1 | 8 | Third | | 4 | 2 | 10 | Fourth | | 5 | 2 | 9 | Fifth | | 6 | 2 | 10 | Sixth | And what we need is to select all docs with docvalues where property_id is 9, thus we intend to get NULL result for those who does not have corresponding record in the docvalues. Right? ...

September 4, 2017 · 2 min · 364 words

PHP yield tl;dr

If you would like to run some php code samples, your own machine is fine, but I would recomment you to use 3v4l.org as a way to execute the code with ~200 different PHP version. That is pretty awesome. So for some time I avoided the yeild and all generator related stuff, honestly I did not get it from the first time and from the second time too… as usual It took some time and perseverence from my side to grok that. ...

August 30, 2017 · 4 min · 714 words

PHP variadic functions

So at first what is a variadic function ? A variadic function is a function that accepts a variable number of arguments, that is it! Starting from PHP 5.6 version we can write it using a special “splat” operator = ... So the simplest example would be this: function variadic(...$args) { return $args; } var_dump(variadic(1,2,3,4)); // and you get it in form of the array [1,2,3,4] In the earlier versions of PHP func_get_args() and func_num_args() were used in order to create variadic functions. The first one gets you all the args in array form and the second you might’ve guessed just gives you a number of args. ...

July 30, 2017 · 1 min · 129 words

Encoging tl;dr

Well, this is my own version of TLDR for an amazing post by David C. Zentgraf. As a self-starter I always struggle to find a good source of information which would give me ample view on the subject and the post writtend by David revealed the whole world of encoding to me. Every text is just a sequence of bytes. Period. There are 128 symbols defined in ASCII table and out of 8 bits ASCII uses only 7. ...

May 28, 2017 · 2 min · 361 words

Pragmatic Programmer synopsis

Here are all the tips from the book Pragmatic Programmer. It was published in October, 1999 and since then became one the best known books about software engineering. Just as I started to write this post, I found that Jeff Atwood already wrote about this post. But I like to finish what I started, so let there be yet another post praising this great book. The list is mostly copy-paste, some day I’ll have time to add my own comments to each Tip, though most if the Tips are pretty self-explanatory. ...

January 14, 2017 · 12 min · 2366 words