0

Possible Duplicate:
Deprecated: Function split() is deprecated. How to rewrite this statement?

I'm getting a Deprecated: function split() is deprecated error on this code.

function getFileExt($filename) {
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts; 

I'm meant to rewrite it or something but I have no idea how!

If somebody could help many thanks!

4

2 回答 2

2

尝试:

function getFileExt($filename) {
    $filename = strtolower($filename) ;
    $exts = explode(".", $filename) ;
    $n = count($exts)-1;
    $exts = $exts[$n];
    return $exts; 
}

同样只是在“。”上使用爆炸。

于 2012-08-23T23:24:17.220 回答
1

函数 split 是一个旧函数。您可以使用爆炸来拆分。

http://www.php.net/explode

于 2012-08-23T23:24:13.093 回答