Skip to content

Instantly share code, notes, and snippets.

@micah1701
Last active Sep 29, 2016
Embed
What would you like to do?
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