简体   繁体   中英

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.

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")
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM