BUG and correction of fgetss_PHP tutorial

WBOY
Release: 2016-07-13 17:23:22
Original
1087 people have browsed it


/*
Author: Zhu Jiang zhu_jiang@263.net
Graduated from Beijing University of Technology
Working, haha, let’s not talk about it, it’s a place I’m not proud of

The fgetss() function provided by the php4.

Regarding the BUG of fgetss, you can use the following code to study it:
$fp=fopen("index.html","r");
while (! feof($fp))
{
$ms=fgetss($fp);
printf($ms);
}
fclose($fp);

Version: Free
* /
function mygets($myFile)
{
//while(!feof($myFile))
//{
$myline = fgets($myFile, 255);

$big=strlen(strstr($myline,">"));
$small=strlen(strstr($myline,"if($big>$small) //This sentence is very important. It is useful if there is a line break in the middle of the HTML code{ //It is useful if > appears first in a line instead of $myline=strstr($myline,">"); $myline=substr($myline,1);
}

$len=strlen($myline);
$startskip=false;
$outstring=""; //important!

for($i=1;$i{ $a=substr($myline,$i -1,1);
switch($a)
{
case "$startskip=true;

//$myline=substr($myline, ">");
//$myline=strstr($myline,1);
break;
case ">":
//$myline=substr($myline,1);
$startskip=false;
break;
default:
}
if(!$startskip && $a!=">") $outstring=$outstring.$a;
}
$outstring=str_replace(" "," ",$outstring);
//Of course, if you don’t want the stuff starting with &, you can add it, just like the same method, here is just filtering
$outstring =str_replace(" ","",$outstring);
$outstring=str_replace(" ","",$outstring); //Double quotes are full-width spaces
$outstring=str_replace(" ","",$outstring);
return $outstring;
//}
} ?>

http://www.bkjia.com/PHPjc/532241.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532241.htmlTechArticle/* Author: Zhu Jiang zhu_jiang@263.net Graduated from Beijing University of Technology and works, haha, don’t mention it, That is a place that I am not proud of. The fgetss provided by the php4.X system...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template