laravel - PHP:在 PHP/Laravel 中的“死”函数之后执行代码
问题描述
我是 PHP 新手,我想开始我从另一个来源复制的 laravel 项目。我收到 500 错误。如果我尝试调试公用文件夹中的 index.php,我会得到一个奇怪的行为,die
如果代码中的内核行在那里,该函数不起作用。我不明白,我认为该die
函数会停止执行。
<?php
die ('hi'); //this die
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
}
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
//If I comment out kernel line "die" on top doesn't return 'hi'. The response is 500 html code.
//$kernel = $app->make(Kernel::class);
/*
$response = tap($kernel->handle(
$request = Request::capture()
))->send();
$kernel->terminate($request, $response);
*/
编辑:来自服务器访问日志的获取日志是:
"GET /index2.php HTTP/2.0" 500 86 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
我在错误日志中没有收到任何错误。所以我已经激活了 PHP 错误日志。我收到此错误消息:
[24-Sep-2020 11:00:39 Europe/Berlin] PHP Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in /usr/.../inertia/public/index2.php on line 44
解决方案
因此,在谷歌搜索 PHP 错误消息后,我发现我的 PHP 版本是 5.6 而不是 7.4,这是一个问题。谢谢大家的帮助!这对我帮助很大。公共文件夹中laravel
有 .htaccess 文件。此文件已将 PHP 版本覆盖为默认 PHP 版本 5.6。
推荐阅读
- node.js - 当用户仅通过命令“/say”时如何处理电报机器人api
- gnuplot - 使用 gnuplot 查找拟合范围
- python - Python plotly Express Histogram:图表未显示所有唯一的 TIME_BUCKET 值,它以每小时值合并 TIME_BUCKET
- kubernetes - 无法通过 kubernetes 中的部署 yaml 上传文件
- algorithm - 子问题大小 wrt Strassen 的矩阵乘法算法
- ruby-on-rails - 处理过期的访问令牌
- c++ - 如何在 swift 项目中使用 .h 文件?.h 是用 C++ 编写的
- c# - .cshtml 文件上的“SelectList”问题给出指令缺失问题
- git - 将所有远程分支拉到你的 fork
- node.js - 我想检查服务器。当我尝试使用:Node server.js 在控制台中运行代码时,它没有运行代码。任何想法为什么?