FirePhoenix Posted February 25, 2007 Share Posted February 25, 2007 Is there any rules on includes as far as how you would include a file from a different location or can you even....? Quote Link to comment https://forums.phpfreaks.com/topic/40048-solved-includes/ Share on other sites More sharing options...
Demonic Posted February 25, 2007 Share Posted February 25, 2007 yes you can only use on the same domain. but you can use File Get Contents or curl/or sockets to get stuff from other sites. Quote Link to comment https://forums.phpfreaks.com/topic/40048-solved-includes/#findComment-193687 Share on other sites More sharing options...
wildteen88 Posted February 25, 2007 Share Posted February 25, 2007 If its a file stored in a remote location (different website) then you can however this will only work if safe_mode is off and allow_url_includes (or allow_url_fopen (depeding on the version of PHP you use) is enabled. Quote Link to comment https://forums.phpfreaks.com/topic/40048-solved-includes/#findComment-193688 Share on other sites More sharing options...
FirePhoenix Posted February 25, 2007 Author Share Posted February 25, 2007 well actually I was meaning like does it have to be in the same directory as the page thats pulling it or can it be in a different directory... I tried <?php include ("config.php"); ?> and it works fine with the file in the same directory but it I do this <?php include ("/admin/config.php"); ?> with it in a different directory it wont work Quote Link to comment https://forums.phpfreaks.com/topic/40048-solved-includes/#findComment-193709 Share on other sites More sharing options...
wildteen88 Posted February 25, 2007 Share Posted February 25, 2007 I see what you mean now. If you want to include a file that is outside of the directory you are in, say you are in mysite/folder1 and you want to include a file that is mysite/folder2 (different directory) then you will use ../ to go one higher in the directory tree. So to get the file that is in mysite/folder2 you'd use this: <?php include "../folder2/myfile.php"; ?> So to get a file that is out side of folder1 and mysite folders you'd use this instead: <?php include "../../myfile.php"; ?> So the first ../ is to go out of the folder1 directory then the secound ../ is to go out of the mysite directory. Hope that helps. You can of course use absolute paths as well rather than relative paths (what I just showed you). But relative paths are much shorter and cleaner to use. Quote Link to comment https://forums.phpfreaks.com/topic/40048-solved-includes/#findComment-193714 Share on other sites More sharing options...
Scriptor Posted February 25, 2007 Share Posted February 25, 2007 If you start a path like: <?php include('/admin/config.php'); ?> It will start by looking for a folder named 'abc' in the root folder. The root folder is the one that hold all of your web files. Quote Link to comment https://forums.phpfreaks.com/topic/40048-solved-includes/#findComment-193716 Share on other sites More sharing options...
FirePhoenix Posted February 25, 2007 Author Share Posted February 25, 2007 Thank you all you have helped alot Quote Link to comment https://forums.phpfreaks.com/topic/40048-solved-includes/#findComment-193915 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.