Manuel PHP

SplFileInfo::getBasename

(PHP 5 >= 5.2.2)

SplFileInfo::getBasenameGets the base name of the file

Description

public string SplFileInfo::getBasename ([ string $suffix ] )

This method returns the base name of the file, directory, or link without path info.

Liste de paramètres

suffix

Optional suffix to omit from the base name returned.

Valeurs de retour

Returns the base name without path information.

Exemples

Exemple #1 SplFileInfo::getBasename() example

  1. <?php
  2. $info = new SplFileInfo('file.txt');  
  3. var_dump($info->getbaseName());  
  4.  
  5. $info = new SplFileInfo('/path/to/file.txt');  
  6. var_dump($info->getbaseName());  
  7.  
  8. $info = new SplFileInfo('/path/to/file.txt');  
  9. var_dump($info->getbaseName('.txt'));  
  10. ?> 

L'exemple ci-dessus va afficher quelque chose de similaire à :

string(8) "file.txt" string(8) "file.txt" string(4) "file"


Remonter Remonter
L'éditeur javascript - CSS - Gentoo - Tutoriaux PHP - Tutoriels PHP - Bretagne - php - Moto - Kit graphique