$ response = file_get_contents($ request)返回false [重复]

This question already has an answer here:

I'm trying to get an XML file with an url:

$request="http://www.example.com/server.php?q=showphonenumbers";
$response = file_get_contents($request);

If I try another request it will show, but somehow this returns false.

var_dump($response); shows: string(8334) " False "

The file looks like this:

<?xml version="1.0"?>
<!DOCTYPE CallOverview>
<CallOverview>
<Calls Count="46">
<Call CallType="GeoCall" Customer="this account" StartTime="2013-11-22 18:58:07 (UTC)" Destination="+1...." Duration="00:23:40"/>
<Call CallType="PSTNOut" Customer="this account" StartTime="2013-11-15 16:48:52 (UTC)" Destination="+1...." Duration="00:00:04"/>
.
.
.
</Calls>
<MoreData>False</MoreData>
</CallOverview>

Could the last False of moredata the only thing that's showing or is the file unreadable?

</div>

On the browser, because you didn't put echo '<pre>';, the browser attempting to render the xml as html, thus only <MoreData>False</MoreData> is considered as text and shown.

If you view the source or run this through cli, you'll see that your content is there.

You can also use header("Content-type: text/plain");.

Maybe it's becouse you didn't put http:// before www..

$request="www.example.com/server.php?q=showphonenumbers";