|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20918 fgetss() does not work
Submitted: 2002-12-10 03:01 UTC Modified: 2003-01-02 18:44 UTC
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ploter at gmx dot ch Assigned:
Status: No Feedback Package: Output Control
PHP Version: 4.3.0RC2 OS: win32
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ploter at gmx dot ch
New email:
PHP Version: OS:


 [2002-12-10 03:01 UTC] ploter at gmx dot ch
i wrote a script, that reads a few htmlpages with the function fgetss(), who strips away the html code. this works propperly in the php-version (php.4.2) 

but with php4.3 something goes wrong and i cant get no output from the function fgetss(). here are the code.
i hope this is a serious problem and it was helpful for you to report this... greets timon

// Liest aus den HTML -Dateien den Text aus
// und strukturiert ihn für die Datenbank.

$fh = opendir("html/") or die("cant read from ./html");
$x = 0;
while($file = readdir($fh)) {
	if($file == '.' || $file == '..') continue;
	$files[$x++] = $file;

echo sizeof($files)." HTML-Dateien ausgelesen...\n";


foreach($files as $file) {
	$fh = fopen("html/$file",'r');
	while($line = fgetss($fh,filesize("html/$file"))) {
		$raw_txt .= zeileputzen($line);
echo sizeof($files)." Dateien wurden geparst...\n";

$fh = fopen('raw.txt','w+');

echo "...und in die Datei <a href=\"raw.txt\">raw.txt</a> geschrieben...\n";

function zeileputzen($zeile) {
	// Tabulatoren, &nbsp;, Linktext usw raus...
	$zeile = str_replace("\t",'',$zeile);
	$zeile = str_replace("nach oben",'',$zeile);
	$zeile = str_replace("&nbsp;",'',$zeile);
	$zeile = preg_replace("/^ */",'',$zeile);
	if(preg_match("/^LvH-Umfeld/",$zeile)) {$zeile = '';}
	if(preg_match("/^Umfeld/",$zeile)) {$zeile = '';}
	if(preg_match("/^Personen/",$zeile)) {$zeile = '';}
	if(preg_match("/^- \w/",$zeile)) {$zeile = '';}
	$zeile = preg_replace("/^\W ?/","",$zeile);
	$zeile = preg_replace("/(B: )/","\n@B: ",$zeile);
	$zeile = preg_replace("/(Br: )/","\n@Br: ",$zeile);
	$zeile = preg_replace("/(K: )/","\n@K: ",$zeile);
	$zeile = preg_replace("/(B: )(\n)/",'B: ',$zeile);
	$zeile = preg_replace("/(Br: )(\n)/",'Br: ',$zeile);
	$zeile = preg_replace("/(K: )(\n)/",'K: ',$zeile);
	return $zeile;

$fh = fopen("raw.txt",'r') or die("unable to read from raw.txt");
$raw_txt = fread($fh,filesize('raw.txt'));

echo "raw.txt ausgelesen\n";

$pieces = explode(chr(10),$raw_txt);
$f = 0;
foreach($pieces as $lines) {
	if(strlen($lines) == 0) { $f++; }
	if(strlen($lines) > 2) { $f = 0; }
	if($f > 10) { 
		$new_buffer .= '###';
		$f = 0;
	echo " :: line -> $lines\n";
	$new_buffer .= $lines."\n";

$f_pieces = explode('###',$new_buffer);

foreach($f_pieces as $l) {
	echo strlen($l);
	if(preg_match("/[A-Za-z0-9]/",$l)) {
		$f_lines = explode(chr(10),$l);
		$new_buffer .= "***";
		foreach($f_lines as $f) {
			if(!strlen($f)) { continue; }
			$f = trim($f);
			$new_buffer .= trim($f)."\n";
$fh = fopen('formatted.txt','w+');

echo "<a href=\"formatted.txt\">formatted.txt</a> geschrieben!\n";
echo "<a href=\"formattedtxt2mysql.php\">text in db eintragen...</a>\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-10 05:31 UTC]
please provide a *short* example showing the problem,
and add expected and actual output ...
 [2003-01-02 18:44 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

 [2003-02-02 03:51 UTC] airtravel at anet dot ne dot jp
I experience similar issue.
fgetss function of PHP4.3.0 doesn't work in any way.
strip_tags(fgets()) works without any problem.

Scripts are working fine with <PHP4.2.3.
I experience the same issue with both on RedhatLinux7.2 and 7.3.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 08 10:01:28 2023 UTC