sayedsohail Posted September 15, 2007 Share Posted September 15, 2007 Hi, I just wish to include two directories in my config.php file so when the user type a.php it will be served from directory a and if the user type b.php it will be served from directory b which is a subdirectory of directory a. require_once( dirname( __FILE__ ) . ); Can someone advise how to do this? Link to comment https://forums.phpfreaks.com/topic/69474-solved-how-to-use-dirname_file_/ Share on other sites More sharing options...
rarebit Posted September 15, 2007 Share Posted September 15, 2007 dirname() just returns the path part of a filename... Are you wanting: if(strcmp($fn, "a.php") == 0) { require_once("a/a.php"); } elseif(strcmp($fn, "b.php") == 0) { require_once("a/b/b.php"); } Link to comment https://forums.phpfreaks.com/topic/69474-solved-how-to-use-dirname_file_/#findComment-349079 Share on other sites More sharing options...
sayedsohail Posted September 15, 2007 Author Share Posted September 15, 2007 thanks for that, i am trying to achieve somthing like this from my url if i type localhost/a/a.php it will dsiplay a.php, now i wish to call b.php using the same url address i.e, localhost/a/b.php instead of localhost/a/b/b.php, since b.php is stored under the subdirectory of directory (a). Link to comment https://forums.phpfreaks.com/topic/69474-solved-how-to-use-dirname_file_/#findComment-349082 Share on other sites More sharing options...
rarebit Posted September 15, 2007 Share Posted September 15, 2007 If you want the url to be rewritten use mod_rewrite (an apache module), otherwise you could redirect (with 'header') or just include b in a... Link to comment https://forums.phpfreaks.com/topic/69474-solved-how-to-use-dirname_file_/#findComment-349086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.