gpt4 book ai didi

php - 如何修复 "Strict Standards: Only variables should be passed by reference"?

转载 作者:行者123 更新时间:2023-11-29 08:45:18 24 4
gpt4 key购买 nike

有人可以帮我解决这 4 行代码吗?我一直在尝试阅读如何修复此错误,但我对 php 还不太熟悉。

$currentFile = $_SERVER["SCRIPT_NAME"];
$img = array_pop(explode("/", $currentFile));
$fileName = basename($img, ".php").PHP_EOL;
echo $fileName;

该脚本查找当前的 $.php 名​​称并将其输出。它还会剪切文件和扩展名的位置......只留下文件名。

我如何编写这 4 行代码才能不抛出严格标准错误

最佳答案

只需添加一个变量即可。

$currentFile = $_SERVER["SCRIPT_NAME"];
$ret = explode("/", $currentFile);
$img = array_pop($ret);
$fileName = basename($img, ".php").PHP_EOL;
echo $fileName;

但是你可以只使用basename,下面的代码会给你相同的结果:

$fileName = basename($_SERVER["SCRIPT_NAME"], ".php").PHP_EOL;

关于php - 如何修复 "Strict Standards: Only variables should be passed by reference"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12659750/

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