我有一个网页,上面有一个按钮,单击该按钮可以执行一个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执行中...等等?
有人可以向我解释“幕后”吗?
答案 0 :(得分:2)
max_execution_time仅影响脚本本身的执行时间。确定脚本已运行的最大时间时,不包括执行脚本之外发生的活动上的任何时间,例如使用system()进行系统调用,流操作,数据库查询等。在测量时间是真实的Windouws中,情况并非如此。
因此,在Linux上,仅计算执行php代码的时间。
“网络”标签中的waiting
只是告诉您,到目前为止,您没有收到网络服务器的任何回复。