[英]How to fix “Strict Standards: Only variables should be passed by reference”?
Can someone please help me with these 4 lines of code. 有人可以帮我这4行代码。 I been trying to read how to fix this error but I'm not very familiar with php that much yet. 我一直试图阅读如何解决这个错误,但我还不是很熟悉php。
$currentFile = $_SERVER["SCRIPT_NAME"];
$img = array_pop(explode("/", $currentFile));
$fileName = basename($img, ".php").PHP_EOL;
echo $fileName;
This script finds the current $.php name and spits it out. 此脚本查找当前的$ .php名称并将其吐出。 It also cuts the location of the file and the extension as well... leaving just the fileName. 它还会切断文件的位置和扩展名......只留下fileName。
How would I write these 4 lines of code to not throw that Strict Standard error 如何编写这4行代码以避免抛出严格标准错误
Just add a varible. 只需添加一个变量。
$currentFile = $_SERVER["SCRIPT_NAME"];
$ret = explode("/", $currentFile);
$img = array_pop($ret);
$fileName = basename($img, ".php").PHP_EOL;
echo $fileName;
But you could just use basename
only, the below code will give you same result: 但是你只能使用basename
,下面的代码会给你相同的结果:
$fileName = basename($_SERVER["SCRIPT_NAME"], ".php").PHP_EOL;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.