全局循环旋转计数器

Is there a way to count, how many spins loops has a PHP file and the files included in it?

I write simple framework and want to keep statistics of rotations made of loops.

include "fiveLoops.php"; // 250 spins 
 while(true){
    break;
    // 1 spin;
 }
 for($i=0;$i<10;$i++){
    // 10 spins; 
 }     
 // total spins 261

Is there has a feature built into the language to give me such information.

There is no built-in function in PHP yet to keep statistics of rotations made of loops. Hence, you need to use a counter that will be stored in the file that includes your function.

To store that variable and include that variable in a different PHP page, your function page, you would want to use a session variable. By default, a session variable stores your variable on the server, not on the clients cookies for around one hour.

You could for instance have $_SESSION['COUNT'] and initiate it to zero in the file that the loop will occur.

When working with session it is important to start the session using session_start and you would put that at the top of every file using session.

On the function page, you would want to retrieve the session variable and increment it accordingly inside your while loop.