Re: strip_tags() problem
| From: | Michael Virnstein | Date: | Fri, 05 Apr 2002 10:59:37 +0000 |
| Subject: | Re: strip_tags() problem | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-91683@lists.php.net to get a copy of this message | ||
or instead of fopen, use:
$fp = fsockopen("http://www.yahoo.com", 80,
$errno, $errstr, 30)
or die ("Could not connect to yahoo.com");
// wait for answer (replacement for deprecated set_socket_blocking)
socket_set_blocking($fp, 1);
i forgot to "die" in the example below, if connection could not be
established.
so
$fp = fopen("http://www.yahoo.com",
"r");
should be
$fp = fopen("http://www.yahoo.com",
"r")
or die ("Could not connect");
or you get an endless while loop on the feof if connection fails.
"Michael Virnstein" <michael.virnstein@brodos.de> schrieb im Newsbeitrag
news:20020405103533.10388.qmail@pb1.pair.com...
> try the following:
>
> $text = "";
> $fp = fopen("http://www.yahoo.com", "r");
> while (!feof($fp)) {
> // read a line and strip all php and html tags
> // there's a third optional parameter, which
> // allowes to specify tags not to be replaced
> $text .= fgetss($fp, 4096);
> }
> fclose($fp);
> echo $text;
> "Ryan Govostes" <panic@twcny.rr.com> schrieb im Newsbeitrag
> news:BC8CE28A-480C-11D6-ACEA-003065E5E422@twcny.rr.com...
> > The following simple code does not function:
> >
> > $html = include("http://www.yahoo.com");
> > $text = strip_tags($html);
> > echo $text;
> >
> > I've tried several variations of the above, such as using preg_replace()
> > instead of strip_tags() and readfile() instead of include(), but it does
> > not work at all, no matter what. Does anyone know why?
> >
>
>