HOME BLOG PORTFOLIO PHOTO CONTACT Admin Login
php code for show your urls dirname,basename,extension,filename with 2 methods

Hello Friends,

This php code for show your urls dirname,basename,extension,filename with 2 methods

 

<?php
//This php code for show your urls dirname,basename,extension,filename with 2 methods
// This work PHP 5.2.0 version or +
// save below line code aoutus.php or any name no problem
echo “<br>Full Url=”.$fullUrl = $_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
$path_parts = pathinfo($fullUrl);
echo “<br>Dir name=”.$path_parts['dirname'];
echo “<br>Base name method1=”.$path_parts['basename'];
echo “<br>Base name method2=”.basename($_SERVER['PHP_SELF']);
echo “<br>Extension name method1=”.$path_parts['extension'];
echo “<br>Extension name method2=”. end(explode(‘.’, basename($_SERVER['PHP_SELF'])));
echo “<br>filename name method1=”.$path_parts['filename'];
echo “<br>filename name method2=”. current(explode(‘.’, basename($_SERVER['PHP_SELF'])));
/*
output like This

Full Url=localhost/jay/17pathinfo/aboutus.php
Dir name=localhost/jay/17pathinfo
Base name method1=aboutus.php
Base name method2=aboutus.php
Extension name method1=php
Extension name method2=php
filename name method1=aboutus
filename name method2=aboutus
*/
?>

   Share on Facebook

Page views:300