Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/122049-require-question/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/122049-require-question/#findComment-630048
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/122049-require-question/#findComment-630055
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/122049-require-question/#findComment-630062
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.