fonction pathinfo PHP ()
Définition et utilisation
pathinfo () retourne un tableau d'informations sur un chemin de fichier.
L'élément de tableau retourné sont les suivantes:
- [Dirname]
- [Basename]
- [Extension]
grammaire
pathinfo(path,options)
参数 | 描述 |
---|---|
path | 必需。规定要检查的路径。 |
options | 可选。规定要返回的数组元素。默认是 all。 可能的值:
|
Trucs et astuces
Remarque: Si tous les éléments de la demande, la fonction pathinfo () retourne une chaîne.
exemple 1
<?php
print_r(pathinfo("/testweb/test.txt"));
?>
print_r(pathinfo("/testweb/test.txt"));
?>
Le code ci-dessus va afficher:
Array
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)
exemple 2
<?php
print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME));
?>
print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME));
?>
Le code ci-dessus va afficher:
test.txt
Remplissez Manuel PHP Référence Filesystem