unemployment Posted June 22, 2012 Share Posted June 22, 2012 Any way to tell php to start at the root directory rather than having all these "../" include('../../../../assets/init.inc.php'); Link to comment https://forums.phpfreaks.com/topic/264607-path-looks-messy/ Share on other sites More sharing options...
trq Posted June 22, 2012 Share Posted June 22, 2012 Have a look at the $_SERVER array. Link to comment https://forums.phpfreaks.com/topic/264607-path-looks-messy/#findComment-1356098 Share on other sites More sharing options...
marcus Posted June 22, 2012 Share Posted June 22, 2012 Just starting the path with a forward slash puts you in the root directory. So the full path would be something like: /home/user/public_html/path/to/assets/init.inc.php Link to comment https://forums.phpfreaks.com/topic/264607-path-looks-messy/#findComment-1356106 Share on other sites More sharing options...
Mahngiel Posted June 22, 2012 Share Posted June 22, 2012 Just starting the path with a forward slash puts you in the root directory. So the full path would be something like: /home/user/public_html/path/to/assets/init.inc.php To which you could also set a definition for ease of future use: <?php define('ASSETS', '/home/user/public_html/awesome_app/views/assets/'); // so include( /home/user/public_html/awesome_app/views/assets/init.inc.php ); // becomes include( ASSETS . 'init.inc.php'); Link to comment https://forums.phpfreaks.com/topic/264607-path-looks-messy/#findComment-1356209 Share on other sites More sharing options...
trq Posted June 23, 2012 Share Posted June 23, 2012 Better yet, add /home/user/public_html/awesome_app/views/assets/ you to your include_path and use: include 'init.inc.php'; Link to comment https://forums.phpfreaks.com/topic/264607-path-looks-messy/#findComment-1356337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.