lamonkey Posted August 31, 2008 Share Posted August 31, 2008 Hi, totally new to PHP here, hope you can help. I have the following code... require ('header.php'); My header is in a totally different URL ex: http://mydomain.com/header.php . How can I get the rquire function to access the header file from this domain URL? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/122049-require-question/ Share on other sites More sharing options...
ForumJoiner Posted August 31, 2008 Share Posted August 31, 2008 When you ask the mydomain.com server for the page http://mydomain.com/header.php, you'll receive the processed version of header.php, not the source page. Example: if header.php is: <?php echo 'Test'; ?> , you'll receive Test instead of the code above. Had what you ask be possible, all our PHP sites would have been down by now It would have been one of the major security risk, to be able to require/include remote files. Quote Link to comment https://forums.phpfreaks.com/topic/122049-require-question/#findComment-630048 Share on other sites More sharing options...
unsider Posted August 31, 2008 Share Posted August 31, 2008 I'm not quite sure why you're asking? You may have to reword your question. Would this have anything to do with cURL? http://us3.php.net/manual/en/curl.examples.php Quote Link to comment https://forums.phpfreaks.com/topic/122049-require-question/#findComment-630049 Share on other sites More sharing options...
lamonkey Posted August 31, 2008 Author Share Posted August 31, 2008 Thanks. Let me ask another way. On my webpage, I want to call both the header and footer PHP scripts from another URL. Currently it uses the require () command, but since it's not a relative address... it doesn't work. Can any of you PHP gurus give me some advice on how to accomplish this??? Again, any help greatly appreciated... Quote Link to comment https://forums.phpfreaks.com/topic/122049-require-question/#findComment-630055 Share on other sites More sharing options...
.josh Posted August 31, 2008 Share Posted August 31, 2008 you can also try file_get_contents, but again, all you're going to get is the parsed output, not any actual serverside code. There is no way to get un-parsed code unless you have direct server access or else the file is permissioned and formatted to be read unparsed. Quote Link to comment https://forums.phpfreaks.com/topic/122049-require-question/#findComment-630062 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.