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 6105847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:00:57+00:00 2026-05-23T14:00:57+00:00

I have two php pages. I want to fetch b.php in a.php. In my

  • 0

I have two php pages. I want to fetch b.php in a.php.

In my a.php:

$ch = curl_init("b.php");
echo(curl_exec($ch));
curl_close($ch);

Doesn’t work;

But:

$ch = curl_init("www.site.com/b.php");
echo(curl_exec($ch));
curl_close($ch);

is OK. I’m sure a.php is under http://www.site.com.

Why curl can’t work with relative path? Is there a workaround?

  • 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-23T14:00:58+00:00Added an answer on May 23, 2026 at 2:00 pm

    Curl is a seperate library which does not really know anything about webservers and where it’s coming from or (philosophicaly) why it is there. So you may ‘fake’ relative urls using one of the two _SERVER variables:

    $_SERVER['SERVER_NAME'] 
    

    The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.

    $_SERVER['HTTP_HOST']
    

    Contents of the Host: header from the current request, if there is one.

    See: http://php.net/manual/en/reserved.variables.server.php

    Edit update:
    I thought a moment longer about this: do you really need to fetch it with curl?
    You usually may also fetch any output of another script like this and save the overhead of loading it through a new http request:

    ob_start();
    require "b.php";
    $output = ob_get_clean();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I have at site where I want pages such as; www.example.com/shop/index.php (or any
I'm not sure if I'm asking this properly. I have two PHP pages located
I have two pages like reg.php and profile.php. in reg.php have a field gender
I want to have two facebook pages open at the same time as part
I have a WP site where I've also got a few php pages outside
lets say i have two pages links.html & contents.php ... first page contains only
have a look at the top menu on these two pages on Firefox: http://outsidemma.com/2010/100031-bj-penn-the-prodigy-jay-dee.php
I have two PHP scripts, both using the same session by calling session_name('MySessID') .
I have two PHP files that I need to link. How can I link
I have two PHP functions to calculate the relation between two texts. They both

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.