#22008 [Opn]: fgetss : 0 vs false, html on multiple lines
| From: | iliaa@php.net | Date: | Mon, 03 Feb 2003 20:59:43 +0000 |
| Subject: | #22008 [Opn]: fgetss : 0 vs false, html on multiple lines | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969351517@lists.php.net to get a copy of this message | ||
ID: 22008
Updated by: iliaa@php.net
Reported By: airtravel@anet.ne.jp
Status: Open
Bug Type: Documentation problem
Operating System: all
PHP Version: 4.3.0
New Comment:
I've tried the latest CVS and tried to fetch the page you've specified.
As far as I can tell the function had worked correctly, only non-html
output was displayed.
P.S. Philip the fgetss() function is supposed to handle tags that span
multiple lines, so that should not be a problem.
Previous Comments:
------------------------------------------------------------------------
[2003-02-02 22:06:07] airtravel@anet.ne.jp
This is something to do with <!DOCTYPE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
seems to be causing problem.
Again PHP4.2.3 or earlier treats this without problem.
------------------------------------------------------------------------
[2003-02-02 21:08:46] airtravel@anet.ne.jp
Thank you for your comments.
I found this problem only occurs when parsing specific html.
Please try the following URL to see my problem.
Thank you.
<?php
$fp =
fopen("http://adds.aviationweather.gov/projects/adds/metars/index.php?metarIds=ksfo",
"r");
while (($line=fgetss($fp, 4096))!==FALSE) {
echo $line;
}
fclose($fp);
?>
<?php
$fp =
fopen("http://adds.aviationweather.gov/projects/adds/metars/index.php?metarIds=ksfo",
"r");
while (($line = strip_tags(fgets($fp, 4096)))!==FALSE) {
echo $line;
}
fclose($fp);
?>
------------------------------------------------------------------------
[2003-02-02 15:46:14] philip@php.net
c) Add a <note> regarding the 'blank lines' comment from Ilia.
I don't think strip_tags() needs this <note> but maybe it does
(doubtful).
------------------------------------------------------------------------
[2003-02-02 15:41:51] philip@php.net
That or maybe a problem existed because it only gets/strips one line at
a time which makes dealing with html tags spanning multiple lines
not-so-good. So using this fgetss() example script vs
strip_tags(file_get_contents($url)) will yield different results.
Reclassifying as a doc problem for fgetss():
a) Add the 0 vs false entity
b) Add a warning regarding spanning html tags; offer an alternative
------------------------------------------------------------------------
[2003-02-02 14:44:04] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
I think the problem you are seeing may stem from incorrect usage of the
fgetss() function. For that reason I am including a sample of a working
code for this function below
<?php
$fp = fopen("http://bugs.php.net/bug.php?id=22008",
"r");
while (($line = fgetss($fp, 4096)) !== FALSE) {
echo $line;
}
fclose($fp);
?>
Note that the output of fgetss gets compared to false, this is very
important because it is quite likely that fgetss() will return 'blanks'
if the line only contains HTML data.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/22008
--
Edit this bug report at http://bugs.php.net/?id=22008&edit=1