简单的 PHP 问题:
为什么这样做,
$exclude_exts = array('js', 'css',);
$filename = "test.css";
$ext = explode('.',$filename);
$is_excluded = in_array(strtolower(array_pop($ext)), $exclude_exts);
但这不是。
$exclude_exts = array('js', 'css',);
$filename = "test.css";
$is_excluded = in_array(strtolower(array_pop(explode('.',$filename))), $exclude_exts);
编辑:两者都曾经在以前版本的 PHP 中工作(我忘了是哪个版本)。
最佳答案
因为 array_pop需要引用,因为它会就地更改数组。
当您传递 explode
的返回值时,那里没有可供引用的变量。
关于php - PHP 中的嵌套函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17811219/