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

search for in the

SplFileInfo::getFileInfo> <SplFileInfo::getCTime
[edit] Last updated: Fri, 24 May 2013

view this page in

SplFileInfo::getExtension

(PHP 5 >= 5.3.6)

SplFileInfo::getExtensionObtiene la extensión del fichero

Descripción

public string SplFileInfo::getExtension ( void )

Devuelve la extensión del fichero.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Devuelve un string que contiene la extensión del fichero, o un vacío string si el archivo no tiene extensión.

Ejemplos

Ejemplo #1 SplFileInfo::getExtension() ejemplo

<?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());

?>

El resultado del ejemplo sería:

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

Notas

Nota:

Este método sólo está disponible a partir de PHP 5.3.6. Otra forma de obtener la extensión es usar la función pathinfo().

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

Ver también



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

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