|
|
Get Current Page Name in php - PHP
|
Views : 251
|
|
Tagged in : PHP
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
If the page is located in sub-folder, then this variable will return the page name
along with sub-folder name also (e.g test/common/index.php)
If you want to get only the filename (e.g index.php).
<?php
$currentpage=$_SERVER['SCRIPT_NAME'];
echo "scriptname : \$_SERVER['SCRIPT_NAME']";
echo "<br>Current page : ".$currentpage."<br>"; // get subfolder/index.php
$currentpage=basename($_SERVER['SCRIPT_NAME']);
echo "<br>Current page : ".$currentpage; // get index.php
echo "<br><br>php self : \$_SERVER['PHP_SELF']";
$currentpage=$_SERVER['PHP_SELF']; // get subfolder/index.php
echo "<br>Current page : ".$currentpage."<br>";
$currentpage=basename($_SERVER['PHP_SELF']); // get index.php
echo "<br>Current page : ".$currentpage;
?> |
|
By Jayanthi, On - 2011-09-28 |
|
|
|