sayedsohail Posted March 6, 2007 Share Posted March 6, 2007 How do i refer my file from a different directory i.e, one level above from the current location/directory. please help. Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/ Share on other sites More sharing options...
kenrbnsn Posted March 6, 2007 Share Posted March 6, 2007 You use ".." to go up a directory tree. For example if your current directory is "/this/is/a/test" to get to a file in the directory "a", you would use "../yat.xyz". So in your case, you would write: <?php require_once('../style.css'); ?> Ken Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201059 Share on other sites More sharing options...
sayedsohail Posted March 6, 2007 Author Share Posted March 6, 2007 what about one directory below. Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201086 Share on other sites More sharing options...
trq Posted March 6, 2007 Share Posted March 6, 2007 <?php require_once 'dirname/style.css'; ?> Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201097 Share on other sites More sharing options...
sayedsohail Posted March 6, 2007 Author Share Posted March 6, 2007 thanks it works. Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201104 Share on other sites More sharing options...
sayedsohail Posted March 6, 2007 Author Share Posted March 6, 2007 is there a way i could create header.php and include all the my subdirectories and than just refer in my all my webpages how do i include different paths in my header.php, please help. require_once(header.php) will automatically include those paths of my directories. Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201145 Share on other sites More sharing options...
trq Posted March 6, 2007 Share Posted March 6, 2007 Take a look at the get_include_path and set_include_path functions, they may help you. Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201154 Share on other sites More sharing options...
sayedsohail Posted March 6, 2007 Author Share Posted March 6, 2007 you mean to say, if i want to include ten different paths than i have to type ten different path in my header.php file. include_path=".;c:\php\config\config.php" include_path=".;c:\php\style\stylesheet.css" include_path=".;c:\php\function\functions.js" and so on. Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201166 Share on other sites More sharing options...
sayedsohail Posted March 7, 2007 Author Share Posted March 7, 2007 you mean to say, if i want to include ten different paths than i have to type ten different path in my header.php file. include_path=".;c:\php\config\config.php" include_path=".;c:\php\style\stylesheet.css" include_path=".;c:\php\function\functions.js" and so on. Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201583 Share on other sites More sharing options...
trq Posted March 7, 2007 Share Posted March 7, 2007 I don't know where you got that from but a path refers to a directory, not a file. You would use something like.... <?php set_include_path( get_include_path(). PATH_SEPERATOR.'c:\php\config'. PATH_SEPERATOR.'c:\php\style'. PATH_SEPERATOR.'c:\php\function' ); ?> And yes, of course you need to add each directory you'll need. Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201612 Share on other sites More sharing options...
nloding Posted March 7, 2007 Share Posted March 7, 2007 The best way I've found is to use a single INCLUDES directory, or single STYLES directory (whatever) then define a constant global variable to handle it. <?php define(DOC_INCLUDES, $_SERVER['DOCUMENT_ROOT'] . "/includes"); require_once(DOC_INCLUDES . "/database.inc"); ?> Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201616 Share on other sites More sharing options...
trq Posted March 7, 2007 Share Posted March 7, 2007 Using my method you would only need to call.... <?php require_once 'database.inc'; ?> Link to comment https://forums.phpfreaks.com/topic/41503-require_once-onelevelabovefromcurrentdirectorystylecss/#findComment-201620 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.