downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SplFileInfo::getFileInfo> <SplFileInfo::getCTime
[edit] Last updated: Fri, 25 May 2012

view this page in

SplFileInfo::getExtension

(PHP 5 >= 5.3.6)

SplFileInfo::getExtensionファイルの拡張子を取得する

説明

public string SplFileInfo::getExtension ( void )

ファイルの拡張子を取得します。

パラメータ

この関数にはパラメータはありません。

返り値

ファイルの拡張子を含む文字列を返します。 拡張子がないときは、空文字列を返します。

例1 SplFileInfo::getExtension() の例

<?php

$info 
= new SplFileInfo('foo.txt');
var_dump($info->getExtension());

$info = new SplFileInfo('photo.jpg');
var_dump($info->getExtension());

$info = new SplFileInfo('something.tar.gz');
var_dump($info->getExtension());

?>

上の例の出力は以下となります。

string(3) "txt"
string(3) "jpg"
string(2) "gz"

注意

注意:

このメソッドが使えるのは PHP 5.3.6 以降です。 拡張子を取得する別の方法には、 pathinfo() 関数があります。

<?php
$extension 
pathinfo($info->getFilename(), PATHINFO_EXTENSION);
?>

参考



add a note add a note User Contributed Notes SplFileInfo::getExtension
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites