Format URL to go to the same directory

/ Published in: PHP
Save to your folder(s)

This allows you to format the URL to go to the directory where the file is placed. Very useful if you are wanting to write server independent PHP Apps.

Copy this code and paste it in your HTML
  1. $location = 'http://'.$_SERVER['SERVER_NAME'].implode("/", explode("/", $_SERVER['PHP_SELF'], -1)).'/';

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.