basename()関数を使うと、引数に指定したファイルのフルパス情報から、ディレクトリ名部分を除いた「ファイル名+拡張子」部分だけを取り出せます。引数には相対パスを指定することもできます。
<?php header("Content-type: text/html; charset=utf-8"); $fullpath = "C:\xampp\htdocs\images\gihyo.gif"; echo $fullpath . "のファイル名は<br>"; echo basename($fullpath) . "<br><br>"; $fullpath = "images/gihyo.gif"; echo $fullpath . "のファイル名は<br>"; echo basename($fullpath) . "<br><br>"; $fullpath = __FILE__; echo $fullpath . "のファイル名は<br>"; echo basename($fullpath) . "<br><br>"; ?>