Is it possible to use curl with relative path in PHP?

Viewed 30900

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 www.site.com.

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

5 Answers
Related