Using pathinfo() Function: The pathinfo() function returns multiple lists containing the identifier name, base name, extension and file name.

example.php

<?php
   // Initializing a variable with filename 
    $file = 'my_filename.html';

   // Extracting only filename using constants 
    $x = pathinfo($file, PATHINFO_FILENAME);

    // Printing the result 
    echo $x;
?> 


Output:

filename