smc Posted March 3, 2007 Share Posted March 3, 2007 Hey everyone, I'm trying to include a file from my root directory but I can't figure out how to. The file that is requiring is in sub.domain.com and the file to be required is in domain.com. How would I go about including it? Thanks!!!!! Link to comment https://forums.phpfreaks.com/topic/41029-requiring-file-from-root-while-in-sub-domain/ Share on other sites More sharing options...
smc Posted March 3, 2007 Author Share Posted March 3, 2007 Any ideas? Link to comment https://forums.phpfreaks.com/topic/41029-requiring-file-from-root-while-in-sub-domain/#findComment-198696 Share on other sites More sharing options...
chronister Posted March 3, 2007 Share Posted March 3, 2007 <?php include('http://path.to.your.file/file.php') ?> Link to comment https://forums.phpfreaks.com/topic/41029-requiring-file-from-root-while-in-sub-domain/#findComment-198721 Share on other sites More sharing options...
genericnumber1 Posted March 3, 2007 Share Posted March 3, 2007 Chronister's method will just cause more headache, never use include() or require() with urls Dont forget you can use absolute paths with includes, or you can use the parent directory option (../) You could do something like include('/etc/apache2/php5/htdocs/myfile.php'); or you could just use the parent directory option with include('../htdocs/myfile.php'); of course you would have to fine tune these to how your directories are set up. Link to comment https://forums.phpfreaks.com/topic/41029-requiring-file-from-root-while-in-sub-domain/#findComment-198727 Share on other sites More sharing options...
chronister Posted March 3, 2007 Share Posted March 3, 2007 Chronister's method will just cause more headache, never use include() or require() with urls ....................... Why do you say this? I have not had any problems using include() even when using with URL's Please explain, because if there is a good reason not to do this, then I want to know why Thanks Link to comment https://forums.phpfreaks.com/topic/41029-requiring-file-from-root-while-in-sub-domain/#findComment-198755 Share on other sites More sharing options...
genericnumber1 Posted March 3, 2007 Share Posted March 3, 2007 When you include via URLs you're normally getting the post-parsed values of pages. Link to comment https://forums.phpfreaks.com/topic/41029-requiring-file-from-root-while-in-sub-domain/#findComment-198756 Share on other sites More sharing options...
chronister Posted March 3, 2007 Share Posted March 3, 2007 Thank you I did not realize that and to test it I tried to include a file that contains a connectdb() function that I made. You are right, the included file is being parsed before it's included so I get a Call to undefined function error rather than it pulling the function in like I expected it to. I learned something new here.... I love this forum Link to comment https://forums.phpfreaks.com/topic/41029-requiring-file-from-root-while-in-sub-domain/#findComment-198803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.