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

  • Home
  • SEARCH
  • 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 4090682
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:16:10+00:00 2026-05-20T19:16:10+00:00

I have a php script that I’m trying to pull some data from a

  • 0

I have a php script that I’m trying to pull some data from a database on one site and display it on another site. I need to reference some files, but using require filename.php throws errors due to my allow_url_fopen being set to off for security reasons. Is there an alternative way to “require” the file using cURL instead?

Example OLD:

<?php require ('http://site.com/filename.php'); ?>

I tried this, but it doesn’t work:

<?php
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://site.com/filename.php');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec($ch);
curl_close($ch);

// display file
require $file_contents;
?>
  • 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-05-20T19:16:11+00:00Added an answer on May 20, 2026 at 7:16 pm

    Ms. Ramsey,

    The most widely accepted solution for your problems in 2011 is to use what’s called a RESTful architecture, which was first widely championed by Yahoo a few years back. It’s REALLLLLLLY easy and not complicated at all as you will soon see.

    First, on the “server” side (where you’re receiving the information) you create a simple RESTful server, the most simplistic one I can think of being (coding on the spot here):

    // RESTful service
    $action = 'action_' . filter_input(INPUT_GET, 'action', FILTER_SANITIZE_STRING);
    $params = filter_input(INPUT_GET, 'params', FILTER_SANITIZE_STRING);
    
    if (function_exists($action))
    {
        // Run the action w/ the parameters
        $data = call_user_func_array($action, json_decode($params));
    
        // Encode the data in a HTTP friendly way...
        $output = json_encode($data);
    
        echo $output;
    }
    else
    {
        trigger_error('Invalid action: ' . htmlspecialchars($action), E_USER_ERROR);
    }
    
    
    function action_foo($param1)
    {
        return "Param 1: $param1";
    }
    

    Now, on your client side, all you have to do is this:

    $ch = curl_init();
    $params = json_encode(array('param1' => 'value', 'param2' => 'value'));
    curl_setopt ($ch, CURLOPT_URL, 'http://site.com/restServer.php?action=foo&params=' . $params);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);
    
    $data = json_decode($output);
    

    It actually works pretty nicely.

    I hope you pick my answer!

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

Sidebar

Related Questions

I have a php script that inserts data from an Android app into a
I have a php script that grabs links from another website. I am storing
I have a PHP script that reads in data from an XML file, returns
I have a php script that takes hierarchical data from a mysql procedure and
I have a PHP script that reads and writes from multiple databases. I am
I have a PHP script that needs to run some pretty hefty imagemagick commands.
I have a PHP script that logs informational and error messages to a database
I have a PHP script that syncs data with a third party service, and
I have a PHP script that I wrote, and one of the pages connects
I have a PHP script that deletes files. It can delete files from my

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.