PHP pathinfo() Function and example


 

PHP pathinfo() Function and example

In this part of the tutorial we will learn about the function pathinfo() in context of file handling. And also we will see the example related to the pathinfo() function

In this part of the tutorial we will learn about the function pathinfo() in context of file handling. And also we will see the example related to the pathinfo() function

Syntax for PHP pathinfo() Function
Array pathinfo(file_path,other options)

  • pathinfo() function returns the dir, base name, extension, and file name.
  • It returns dir, base name, extension etc in the form of the array of the given file.


PHP pathinfo() Function with Example

Code/Syntax of PHP pathinfo() Function

<?php
    $ar1
=pathinfo("aa.txt");
    foreach
($ar1 as $k=>$v)
       {
      echo
$k."->".$v."<br/>";
       }
?>


Output

dirname->.
basename->aa.txt
extension->txt
filename->aa

Ads