php - "Strict Standards: Only variables should be passed by reference"错误

标签 php

<分区>

我正在尝试根据此处的代码获取基于 HTML 的递归目录列表:

http://webdevel.blogspot.in/2008/06/recursive-directory-listing-php.html

代码运行良好,但会抛出一些错误:

Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\directory5.php on line 34

Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\directory5.php on line 32

Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\directory5.php on line 34

以下是代码摘录:

else
  {
   // the extension is after the last "."
   $extension = strtolower(array_pop(explode(".", $value)));   //Line 32

   // the file name is before the last "."
   $fileName = array_shift(explode(".", $value));  //Line 34

   // continue to next item if not one of the desired file types
   if(!in_array("*", $fileTypes) && !in_array($extension, $fileTypes)) continue;

   // add the list item
   $results[] = "<li class=\"file $extension\"><a href=\"".str_replace("\\", "/",     $directory)."/$value\">".$displayName($fileName, $extension)."</a></li>\n";
  }

最佳答案

这样应该没问题

   $value = explode(".", $value);
   $extension = strtolower(array_pop($value));   //Line 32
   // the file name is before the last "."
   $fileName = array_shift($value);  //Line 34

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

相关文章:

php - 符号链接(symbolic link)真实世界的例子

PHP-MySQL INSERT 操作不工作

php - Mysqli - 将结果绑定(bind)到数组

php - 在 Symfony 1.4 中的每个 Action 后执行代码

php - 是否可以在 PHP 函数中定义局部常量?

php - 运行 Symfony 控制台命令后 Docker php-fpm 容器退出并显示代码 0

php - 无法通过 MAMP 连接到 MySQL

PHP Prepared Statement MySQL in-function with integers not string

javascript - 使用 PHP 和 Javascript 将字母数字值作为函数内的参数传递时出现错误

php - PHP 电子邮件中 ​​ "from" header 字段防止标记为垃圾邮件的最佳实践