Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

file_get_contents not returning entire webpage

I've been trying to retrieve the contents of a webpage (http://3sk.tv) using file_get_contents. Unfortunately, the resulting output is missing many elements (images, formating, styling, etc...), and just basically looks nothing like the original page I'm trying to retrieve.

This has never happened before with any other URLs I have tried retrieve using this same method, but for some reason, this particular URL (http://3sk.tv) refuses to work properly.

The code I'm using is:

<?php
$homepage = file_get_contents('http://3sk.tv');
echo $homepage;
?>

Am I missing anything? All suggestions on how to get this working properly would be greatly appreciated. Thank you all for your time and consideration.

like image 362
jameslanvin Avatar asked Dec 16 '15 14:12

jameslanvin


People also ask

What will the file_get_contents () return?

Return Values ¶ The function returns the read data or false on failure. This function may return Boolean false , but may also return a non-Boolean value which evaluates to false . Please read the section on Booleans for more information.

Does file_get_contents cache?

Short answer: No. file_get_contents is basically just a shortcut for fopen, fread, fclose etc - so I imagine opening a file pointer and freading it isn't cached.

What is the function file_get_contents () useful for?

The file_get_contents() reads a file into a string. This function is the preferred way to read the contents of a file into a string. It will use memory mapping techniques, if this is supported by the server, to enhance performance.


1 Answers

Thats normal behaviour, as you are only grabbing the file, and not related images, stylesheets etc...

like image 170
RFLdev Avatar answered Sep 19 '22 14:09

RFLdev