I read data from binary file which contains names of domains separated by semicolon. I have saved one word "localhost;" into the position.
I tried more versions, the main difference is with the use of last condition of the while loop:
$word=$byte=""; fseek( $fh , $n );echo "n is $n;"; while ( $byte=fread($fh,1) && bindec($byte)!=59) // semicolon is ord 59 ... && ord($byte)!=0 { echo "<b>".$byte."</b>"; $word.=$byte; } echo ":$word==".$_SERVER["HTTP_HOST"]."<br>".ord($byte); if ( $word==$_SERVER["HTTP_HOST"] ) return false; // this domain is blocked
First of all I tried this:
while ( $byte=fread($fh,1) && $byte!=";")
none works:
while ( $byte=fread($fh,1) && chr($byte)!=";")
also no success:
while ( $byte=fread($fh,1) && ord($byte)!=";")
It should print localhost==localhost ... however I am getting number one instead (repeated ).
If I will skip the last condition, the localhost is printed commonly with the rest of the file (but I need to break it).
Any idea what I do wrong?