gpt4 book ai didi

php - php max_execution_time 实际测量的是什么?

转载 作者:搜寻专家 更新时间:2023-10-31 20:57:26 26 4
gpt4 key购买 nike

我有一个网页,上面有一个按钮,单击该按钮会执行一个 php 函数。

当用户点击它时,需要 51081ms 返回一个页面。其中 51376 毫秒被我的 Firefox 开发人员工具中的“网络”选项卡归类为“等待”。

我的 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代码的时间。

网络选项卡中的等待只是告诉您直到现在您还没有从网络服务器收到任何响应。

关于php - php max_execution_time 实际测量的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54694824/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com