File_get_contents not working for local files?

Php include($_SERVER'HTTP_HOST' . "/my_dir/my_css_file. Css");?

Or? Php include($_SERVER'DOCUMENT_ROOT' ."/my_dir/my_css_file. Css");?

Updates corresponding your comments: $string = get_include_contents('somefile. Php'); function get_include_contents($filename) { if (is_file($filename)) { ob_start(); include $filename; $contents = ob_get_contents(); ob_end_clean(); return $contents; } return false; } This will get file data into variable $string.

Try to use include() instead of file_get_contents(). Or Updates corresponding your comments: $string = get_include_contents('somefile. Php'); function get_include_contents($filename) { if (is_file($filename)) { ob_start(); include $filename; $contents = ob_get_contents(); ob_end_clean(); return $contents; } return false; } This will get file data into variable $string.

I need to get this data into a variable that's why file_get_contents is essential. Not sure if I can do the same with include()? – Chuck Ugwuh Aug 11 '10 at 12:21 @Chuck - Have you checked your file permissions?

– webfac Aug 11 '10 at 12:29 @Chuck Ugwuh - try updated answer. – Brain Aug 11 '10 at 12:35 @lgnatz - Nice variation on file_get_contents(), I like it. – webfac Aug 11 '10 at 12:40 This looks like it would work.

Unfortunately, I have a separate ob_start() implementation going on with my page. I'm trying to see if I can work something out with CURL. – Chuck Ugwuh Aug 11 '10 at 15:03.

Solved this by using CURL. Here's the code. It will work with remote files e.g. yourdomain.com/file.ext $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ''.

$file_path_str. ''); curl_setopt($ch, CURLOPT_HTTPGET, 1); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5))); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $curl_response_res = curl_exec ($ch); curl_close ($ch).

There is a bug in a combination of Windows, file_get_contents and localhost which is not going to be fixed. See bugs.php.net/38826 and bugs.php.net/40881 Try using 127.0.0.1 instead of localhost or set up any different domain name. Then you should get it working.

Yes I'm on Windows. I'm actually not using localhost per se. I have a lot of domain names defined in my hosts file, and also in my apache.conf.So I can setup something like mydomain/myfiledir/myfile.

Css for example. Is there a workaround for this?! – Chuck Ugwuh Aug 11 '10 at 11:58 Is file() working?

Did you try @Ignatz's solution? – sprain Aug 11 '10 at 13:33.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions