pathinfo function to get file details of a file path

We can use pathinfo() to get details of the file path. We can input a file path and get the directory name, basename (file name with extension), file name without extension and the file extension. The function pathinfo returns an array.
//$file = $_SERVER["SCRIPT_NAME"]; // Takes the current file name
$file=''; // Path is stored in Variable
//echo print_r($path_details);
echo $path_details['dirname']; // Output is: <i></i>

echo "<br>";
echo $path_details['basename']; // Output is: <i>path.php</i>
echo "<br>";
echo $path_details['extension']; // Output is: <i>php</i>
echo "<br>";
echo $path_details['filename']; // Output is: <i>path</i>


Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here .

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 All rights reserved worldwide Privacy Policy Disclaimer