[suspicious - maybe spam] note 49682 added to function.file-get-contents

From: Date: Fri, 04 Feb 2005 17:22:52 +0000
Subject: [suspicious - maybe spam] note 49682 added to function.file-get-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-84532@lists.php.net to get a copy of this message
Fellow PHP'ers, If you are using a version of PHP 4 < 4.3.0, you propably already understood that you can not use "file_get_contents", normally. Using the lines of code below you have access to "file_get_contents" trough out PHP 3, PHP 4 , PHP 5. <? if (!function_exists("file_get_contents")) { function file_get_contents($file) { return(implode("", file($file))); } // file_get_contents. } // !function_exists("file_get_contents"). /* For example we are including a file from another website, we will use Google ;) in this example (since I use it every day). We know just use "file_get_contents" like we would have done in case our server supported PHP 4 < 4.3.0. file_get_contents(string filename) */ // Load the to contents of the file into the variable called $str. $str = file_get_contents('http://www.google.com/'); // Since pictures in an external webpage would not be dispayed properly if there src is set // to a relative path; replace all instances of relatives with absolutes. echo str_replace('src="/', 'src="http://www.google.com/', $str); /* I would not be using the above example, or any other cross-domain solution, without the secondary party's consent. */ ?> I repeat, I would not be using the above example, or any other cross-domain solution, without the secondary party's consent. Jay Kamminga ---- Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49682 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49682&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49682&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49682&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49682&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49682&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49682&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84532) next »