Krash Posted February 8, 2011 Share Posted February 8, 2011 Been using these includes in php4 for a long time, but they don't work in php5. Page loads, but included code is blank. <?php include("http://www.xxxxxxxx.org/header.php"); ?> Link to comment https://forums.phpfreaks.com/topic/227018-include-doesnt-work-in-php5/ Share on other sites More sharing options...
lastkarrde Posted February 8, 2011 Share Posted February 8, 2011 You shouldn't try to include a URL, you should include a path in the filesystem. eg include('path/to/header.php') Link to comment https://forums.phpfreaks.com/topic/227018-include-doesnt-work-in-php5/#findComment-1171268 Share on other sites More sharing options...
Krash Posted February 8, 2011 Author Share Posted February 8, 2011 I can use a relative path if the included file is in the same directory or below, but I can't include a file that's above the current directory. Is there a way to do that? Link to comment https://forums.phpfreaks.com/topic/227018-include-doesnt-work-in-php5/#findComment-1171270 Share on other sites More sharing options...
Pikachu2000 Posted February 8, 2011 Share Posted February 8, 2011 Of course there is. You can use $_SERVER['DOCUMENT_ROOT'] to use the path relative to the root of the web server. include($_SERVER['DOCUMENT_ROOT'] . '/path/to/file.php'); Link to comment https://forums.phpfreaks.com/topic/227018-include-doesnt-work-in-php5/#findComment-1171288 Share on other sites More sharing options...
Krash Posted February 8, 2011 Author Share Posted February 8, 2011 Yeah, found that and it works fine. If I were a bit younger, and a lot smarter, I'd sit myself down and actually learn this stuff. But if I had some ham, I'd make ham & eggs, if I had some eggs. Thanks! Link to comment https://forums.phpfreaks.com/topic/227018-include-doesnt-work-in-php5/#findComment-1171291 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.