Knowledgebase: PHP
How to include URL or file in PHP codes
Posted by on 09 May 2013 10:40 PM

There are 2 scenarios here:

1. To include a PHP file inside hosting space:

eg:

Document root: /home/user/public_html/

Index page: /home/user/public_html/index.php

header to be included: /home/user/public_html/include/header.php

Here you can use relative path in index.php:

<?

include "./include/header.php";

?>

2. To include a URL in PHP codes:

eg:

If the PHP page to be included is an external URL, you would need to enable allow_url_include in PHP.INI. Do note that allowing allow_url_include is a security risk and this is not enabled by default on our shared servers. See http://blog.arvixe.com/setting-custom-php-ini-files-for-your-website/ to see the steps to enable custom php.ini (set allow_url_include to "On" there).

allow_url_include only needs to be enabled if it is an external URL and you need to include that in your codes.

(4 vote(s))
Helpful
Not helpful

Comments (2)
Javan DeLoach
24 June 2015 06:42 PM
My Web site features pictures of our groups cycling activities and news of coming events. The pictures are normally consolidated every two weeks on their own web page. I have a header file, navbar.htm, which provides navigation between all of the Web pages.
On my previous host, I used the "include" command on each Web page so that when navbar.htm was updated, I only had to post it once. This is not working on the Arvixe host.
I saw the two articles in the knowledge base, and using that suggestion did not work either.
I want to place the navbar.htm in a directory named "includes", then be able to call it up on all of the Web pages.
My web site is "fos.bike".
Thanks for any help that you can provide.
Ryan C
06 July 2015 10:06 PM
Hello Javan,

Please reach out to our support department so that way we can take a closer look at this. It's hard to comment with the limited amount of details.

Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).