Example 1 — Split a Path Into Parts
Print every part of a file path.
<?php
$info = pathinfo('/var/www/html/photo.final.jpg');
print_r($info); How It Works
- dirname is everything before the last slash.
- basename is the file name with its extension.
- extension is the text after the last dot, here jpg.
- filename is the basename without the extension, so photo. final stays together.

