English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutoriel de base PHP

Tutoriel avancé PHP

PHP & MySQL

Manuel de référence PHP

Utilisation et exemple de la fonction pathinfo() en PHP

PHP Filesystem Référence Manuel

La fonction pathinfo() peut retourner un tableau contenant des informations sur le chemin. Si des options sont spécifiées, elles retourneront les éléments spécifiés ; ils incluent : PATHINFO_DIRNAME, PATHINFO_BASENAME et PATHINFO_EXTENSION ou PATHINFO_FILENAME. Si les options ne sont pas spécifiées, le retour par défaut est l'ensemble des éléments.

Syntaxe

mixed pathinfo ( string $path [, int $options = PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME ] )

Cette fonction pathinfo() peut retourner des informations sur le chemin : tableau associatif ou chaîne de caractères, selon les options.

Exemple1

<?php
   print_r(pathinfo("/PhpProject/simple.txt"));
?>

Résultat de la sortie

Array
(
    [dirname] => /PhpProject1
    [basename] => simple.txt
    [extension] => txt
    [filename] => simple
)

Exemple2

<?php
   print_r(pathinfo("/PhpProject/simple.txt, PATHINFO_BASENAME));
?>

Résultat de la sortie

simple.txt

PHP Filesystem Référence Manuel