Skip to content

Instantly share code, notes, and snippets.

@micah1701
Last active September 29, 2016 18:30
Show Gist options
  • Save micah1701/4cf2ad34e3cf6134b796865fa3b9c657 to your computer and use it in GitHub Desktop.
Save micah1701/4cf2ad34e3cf6134b796865fa3b9c657 to your computer and use it in GitHub Desktop.
Determine the server and web directory of the current file.
<?php
/**
* set the server directory that this application is stored in.
* if applicaiton is in the root directory, set to "/"
*/
$_app_server_path = rtrim(str_replace('\\', '/', dirname(__FILE__)),"/")."/"; // eg: "/home/ubuntu/workspace/my-website/"
$web_app_path = str_replace(rtrim($_SERVER['DOCUMENT_ROOT'],"/"),'',$_app_server_path); // eg: "/my-website/" or just "/" if in root
define('_app_path',$web_app_path);
define('_app_server_path',$_app_server_path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment