Re: put result of "include" into a variable

From: Date: Fri, 22 Nov 2002 23:43:46 +0000
Subject: Re: put result of "include" into a variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-125692@lists.php.net to get a copy of this message
At 23:36 22.11.2002, Patrick Anderson at TUE said: --------------------[snip]-------------------- >For some (strange, I know) reason I would like to copy the content of a >webpage into a database. > >I would like to have code like > >$whocares = include ("http://www.microsoft.nl"); >$query = "insert into html values ($whocares,...)"; >.. > >However, include can not copy the content to a variable. Does anyone >have an idea how to circumvent this problem? --------------------[snip]-------------------- It's kinda strange you want to keep M$'es page in a database... *g* $fp = fopen('http://www.microsoft.nl', 'r'); if ($fp) { $buffer = null; while ($chunk = fread($fp, 512*128)) // get in 512k chunks $buffer .= $chunk; fclose($fp); str_replace('\'', '\'\'', $buffer); $query = 'insert into html(thepage) values (\''.$buffer.'\')'; } else die('No connection to Microsoft'); -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#125692) next »