doulu4316 2015-07-16 12:17
浏览 29

全局循环旋转计数器

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.

  • 写回答

1条回答 默认 最新

  • douyalin2258 2015-07-16 12:33
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题