Q:

PHP program to print the filename of the current executing PHP script

belongs to collection: PHP Miscellaneous

0

Here, we will use $_SERVER['PHP_SELF'] superglobal to get the name of the currently executing file and print that on the webpage.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.

<?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.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

PHP Miscellaneous

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
PHP program to print the version of CGI used by th... >>
<< PHP program to demonstrate the use of $GLOBALS to ...