The source code to print the filename of the current executing PHP script is given below. The given program is compiled and executed successfully.
<?php
//PHP program to print the filename of
//current executing PHP script.
$fileName = $_SERVER['PHP_SELF'];
printf("File Name: %s<br>", $fileName);
?>
Output:
File Name: prog.php
Explanation:
In the above program, we used $_SERVER['PHP_SELF'] super global that returns the name of the currently executing file, which is assigned to the variable $fileName. After that, we printed the file name using printf() on the webpage.
Program/Source Code:
The source code to print the filename of the current executing PHP script is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we used $_SERVER['PHP_SELF'] super global that returns the name of the currently executing file, which is assigned to the variable $fileName. After that, we printed the file name using printf() on the webpage.
need an explanation for this answer? contact us directly to get an explanation for this answer