Joe Morgan
Joe Morgan

Reputation: 175

file_get_contents with get variable

I have a site that is in php and generates a report

Im trying to convert to a PDF

My code:

<?php
file_get_contents("http://domain.com/report.php?clid=Company Name");
?>

I get a Blank Page

If i go to:

http://domain.com/report.php?clid=Company Name

Page renders fine

If i run:

php testhtml.php

I get no errors.

Any help would be greatly appreciated.

Upvotes: 0

Views: 179

Answers (1)

Federkun
Federkun

Reputation: 36934

From the documentation of file_get_contents:

If you're opening a URI with special characters, such as spaces, you need to encode the URI with urlencode.

Also, remember to echo it:

echo file_get_contents(
    "http://domain.com/report.php?clid=". urlencode("Company Name")
);

Upvotes: 1

Related Questions