Please explain how you can use declare constructively for any business. The mane says that it can be used to measure the execution time of code sections, and the most interesting thing is that it is supposed to be multithreading. If possible, provide code examples using this construct. It is desirable for the organization of multitrading, well, for measuring the runtime too.

  • There is no "multitreding" in php, if it were, and even so simply organized, you would already know about it. An example for measuring the time is on the Internet, just enough to drive something - declare php - Zowie

1 answer 1

It is described in sufficient detail: declare .

The declare construct is used to set the execution directives for a block of code. The declare syntax is similar to the syntax of other execution control constructs.

In fact, the tick directive is of interest. The point is that for every line; and the {} block turns a tick, for example:

function notifyTick() { print "This is tick"; } register_tick_function("notifyTick"); 

and let there be two options

 declare(ticks=1) echo 'Hello!'; 

and

 declare(ticks=1) {{ echo 'Hello!'; }} 

then in the second case there will be more ticks than in the first.

Tics are not an analogue or a replacement for multithreading, as @AlexWindHope rightly noted.