簡體   English   中英

在PHP中嵌套函數

[英]Nesting functions in PHP

簡單的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的返回值時,沒有可供引用的變量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM