getting php file name

This example demonstrate how to find out php file name. in the following example first absolute path will be find out, and then the file name.

<?php
 
//-----Getting full path
$fullPath =  __FILE__;
 
 
//-----Getting only file name with basename
  
echo basename($fullPath, ".php").PHP_EOL;
//Given a string containing the path to a file or directory,
//this function will return the trailing name component.
 
?>