Please bear with me, I'm trying to learn php and all about how deal with files & setup on the server side. All was fine until I recently had to switch my hosting site. This new hosting site has their url_fopen
turned off.
My previous script was using:
file_get_contents ("that.htm");
but now I need to use cURL. I've figured out how to load a remote file without any problems. I then save it (still using file_put_contents
since it's not restricted) and re-access this cached file as follows:
$path = $_SERVER["PHP_SELF"];
$file = replace("this.php","that.htm",$path);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
*note: "this.php" is the file conatining the above script and "that.htm" is the cached file in the same directory (it doesn't have all the html inside of it like <html>
or <body>
, but it does have a <table>
, if that makes a difference). Also, the file permissions of "that.htm" are set to 777.
My problem is I don't get any output from the $data (and I can see the "that.htm" has the appropriate contents as I can load the file directly in the browser).
So I get no output setting the $file:
- using $_SERVER["PHP_SELF"] & replacing the filename
- using just the file name
- using the complete URL (e.g. http://myhostsite.com/mydirectory/that.htm)
I tried to add a var_dump after the $data but apparently the script never gets to that point.
I'm sure it's something silly, but in my searching of the net and this site I can't figure it out (all the examples just say "http://example.com").