微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php max_execution_time实际测量的是什么?

我有一个网页,上面有一个按钮,单击该按钮即可执行一个PHP函数.

用户单击它时,需要51081ms才能返回页面.在我的Firefox开发人员工具中,“网络”选项卡将其中的51376毫秒归类为“等待”.

在我的PHP.ini文件中声明的max_execution_time为30.我在PHPinfo文件中也可以看到此信息.

我的问题是,为什么我的脚本在30秒后不超时? max_execution_time实际测量的是什么?

编辑以包含代码

public function getSlotsByUser (Request $request) {

    $event_id = $request->event_id;
    $user_id = substr($request->user, 4);

    $event = Event::find($event_id);

    $user = User::find($user_id);

    $slots = TimeSlot::where('event_id',$event_id)->get();

    $userSlots = $user->slots;

    foreach($userSlots as $userSlot) {

       $guest = Guest::where('slot_id',$userSlot->id)->where('user_id',$user->id)->first();

       if($guest) {
            $userSlot->guest_id = $guest->id;
            $userSlot->guest_name = $guest->name . ' ' . $guest->surname;
        }
        else {
            $userSlot->guest_id = NULL;
            $userSlot->guest_name = NULL;
        }

        $userSlotIds[] = $userSlot->id;

    }

    $days = new DatePeriod(
         new DateTime($event->start_time),
         new DateInterval('P1D'),
         (new DateTime($event->end_time))->modify('+1 day')
    );

    return view('admin.calendar',compact('event','slots','user','userSlots','userSlotIds','days'));

}

我了解哪些部分代表使用Eloquent的查询.我的代码也去了;

PHP执行

PHP执行

数据库查询

数据库查询

数据库查询

PHP执行…等?

有人可以向我解释“幕后”发生了什么吗?

解决方法:

set_time_limit说:

max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windouws where the measured time is real.

因此,在Linux上,仅计算用于执行PHP代码的时间.

“网络”标签中的等待状态只是告诉您,到目前为止,您没有从网络服务器获得任何响应.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐