PHP

$a = &$b vs $a =& $b

Anyone who works with PHP probably knows what “assignment by reference” is.
This is an instruction like $a = &$b, which essentially means that the variable $a is a reference to the variable $b. That is, as a result:

the value 20 will be displayed, since $a simply references $b.

And such a record, in my opinion, looks logical. On the left is the variable to which we assign something, in the middle is the assignment operator “=”, on the right is what we assign – a reference to the variable $b, which, to show that this is a reference, is designated with &.

However, it turns out that there is a completely equivalent record of the same instruction, in the form:

$a =& $b;

It works completely equivalently. As a result, $a will still be a reference to $b.

But for me, such a notation is much less informative. I always get stupefied when I see the unfamiliar assignment operator “=&”, which, when written this way, is caught by the eye in the middle.

Apparently, someone finds such a notation more convenient. But what is its convenience?
I can’t understand.

PHP: How to export HTML to DOC

When developing online projects, it is often necessary to save the HTML page as a document that can be used separately, for example, sent by e-mail, viewed and edited offline. A convenient way is to export the HTML page to one of the most commonly used text formats – doc.

The free open-source PHP-module “html_to_doc” can be used to export the HTML page to the DOC document. It can convert the HTML to the DOC document, which will be correctly processed by the text editor MS Word. If the HTML page includes images, they will be embedded in the DOC document.

The PHP module can be downloaded from https://github.com/Korchy/html_to_doc

PHP: How to get the full class name with static inheritance

PHP supports the Late Static Bindings mechanism. The full class name with static inheritance we can get by calling the function:

Example:

 

How to check code execution time in PHP

To check how match time code execution takes you need to frame checking code with following instructions:

This example result:

Executed for: 8.9997079372406 sek.