MasterACE14 Posted February 27, 2009 Share Posted February 27, 2009 hey, I just want to include a file. I'm just not sure how you include it when it's in another folder to where the file calling it is. folder structure: Main Directory -> css -files to include- -> lib -including the files in css folder above- and my code for files within the 'lib' folder: <?php $style = $_SERVER['DOCUMENT_ROOT']."/css/".$style.".css"; any help is appreciated. Regards, ACE Link to comment https://forums.phpfreaks.com/topic/147142-include-file-in-a-different-folder/ Share on other sites More sharing options...
jackpf Posted February 27, 2009 Share Posted February 27, 2009 Could you not just <link> to it? If not, you could use include('../css/'.$style.'.css'); The two dots and forwardslash at the front should take you up a directory Hope this helps. Link to comment https://forums.phpfreaks.com/topic/147142-include-file-in-a-different-folder/#findComment-772456 Share on other sites More sharing options...
MasterACE14 Posted February 27, 2009 Author Share Posted February 27, 2009 hmm, doesn't seem to be changing anything. <?php // function inside my class public function Style($style="default") { $style = "../css/".$style.".css"; if(is_file($style)) { echo "<style><!--"; include($style); echo "--></style>"; } } $client = new Client(); $client->Style(); // in the CSS file included it changes background and text color of a table // a HTML table is here but without any of the CSS changes ??? any ideas? Link to comment https://forums.phpfreaks.com/topic/147142-include-file-in-a-different-folder/#findComment-772462 Share on other sites More sharing options...
jackpf Posted February 27, 2009 Share Posted February 27, 2009 Hmm...that's what I use- seems to work. Could maybe be something to do with your php config? Idk, I'm out of ideas. Sorry dude. Link to comment https://forums.phpfreaks.com/topic/147142-include-file-in-a-different-folder/#findComment-772529 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.