Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8322491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:24:25+00:00 2026-06-08T23:24:25+00:00

I recently upgraded from php4 to php5 and with it came the notice that

  • 0

I recently upgraded from php4 to php5 and with it came the notice that all my remote php file access no longer worked. I’ve been doing quite a bit of research into this and I dont seem to have a clear answer as to what is the correct way to include remote urls in php5.

The first example is to include the file this way

<?php
   $data = file_get_contents("http://example.com/example.inc.php",0);
   echo $data;
?>

The 2nd is this way

<?php
   $ch = curl_init("http://example.com/example.inc.php");
   curl_exec($ch);
   curl_close($ch);
?>

and 3rd is to set in my php.ini file

allow_url_include = On      
allow_url_fopen = On

and use the good old

<?php include_once('http://example.com/example.inc.php');?>

I want to do this right and secure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:24:27+00:00Added an answer on June 8, 2026 at 11:24 pm

    All solutions are correct and there is no real difference in safety AFAIK.

    I think the difference can be summed up like this:

    The ini-settings provide the behaviour as known from prior versions. The reason why they are disabled by default is the security thread, but that is equal to all three solutions. Including remote files is a security problem, regardless of whether you control the rmeote site or not.

    file_get_contents() and the curl extension creates some overhead, since you have to buffer the content, but for php include files that is more a cosmetic thing. Their usage is slightly more complex when reading through a script. But the buffering also adds benefits: you might create a local cache for example or a checksum towards a basic plausibility check. Also a syntax check prior to execution is possible thus preventing the crash of your calling script.

    Curl is provided as a php extension. So the curl solution only works when the extension is installed, but it offers a much higher grade of freedom, much more options. If you don’t require those stay with the builtin functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We recently upgraded a server from PHP4 to PHP5.4 There is an application running
We recently upgraded from Access 2000 to 2007, and it broke an aspect of
I am using PHP 5.3 on Ubuntu 10.0.4. I recently upgraded from PHP 5.2
I recently upgraded from 4.0.1 to 4.2.1 and noticed that when I publish to
We just recently upgraded from VS2005 to VS2010. I've noticed that unlike VS2005, when
I'm currently working with a rails 3.0.x app that's recently been upgraded from rails
I recently upgraded my projects from VS2005 to VS2008. I use a .resx file
We have recently upgraded all our projects from .NET 3.5 to .NET 4. I
I recently upgraded from a GTX480 to a GTX680 in the hope that the
I recently upgraded from jQuery 1.2.6 to 1.3.2 Now on the page I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.