PHP Magic Book – Free PHP Scripts, Tutorials and Downloads, PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips

Find File Path At Server Using PHP

I have other solutions to find file path at server or file name using PHP. The thing is, some php scripts might not work with some versions of PHP or in some situations. So more methods you learn for each task with PHP, the better. Here goes more solutions; Enjoy!

In this example I used CurrentpageURL.php page and tested it via wamp server at local host.

<?php
echo htmlspecialchars($_SERVER['REQUEST_URI'])
?>

Display
/CurrentpageURL.php

<?php
echo $_SERVER['REQUEST_URI']
?>

Display
/CurrentpageURL.php

<?php
$url = sprintf("%s%s%s","http://",$HTTP_HOST,$REQUEST_URI);
echo "$url";
?>

Display
http://localhost/CurrentpageURL.php

<?php
$sPage = explode("/", $_SERVER['PHP_SELF']);
$rs= $sPage[count($sPage)-1];
echo "$rs";
?>

Display
CurrentpageURL.php

Download Script

  • Share/Bookmark
Tags: , ,
Posted in: File, URL, Useful Scripts
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0

Related Posts




Post a Comment

  Subscribe Via RSS
  Subscribe Via Email