note 49682 deleted from function.file-get-contents by nlopess

From: Date: Fri, 04 Feb 2005 18:29:13 +0000
Subject: note 49682 deleted from function.file-get-contents by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-84538@lists.php.net to get a copy of this message
Note Submitter: nomail at my dot address Reason: useless ---- 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

« previous php.notes (#84538) next »