Fputs () What happens when an exception occurs?
Page Tip:
Assembly Code
Warning:fputs () expects parameter 1 to BES resource, boolean given in x.php on line 100warning:feof () expects parameter 1 To is resource, boolean given in x.php on line 101warning:fgets () expects parameter 1 to being resource, boolean given in X . PHP on line 102
The prompt is the three lines of the loop output, about dozens of hundreds of rows, the page stuck, I directly shut down the browser
It is not always the case, most of it is normal, but occasionally encounter the connection when the error will occur
x.php file:
PHP Code
$data = ""; $text = "XAWASDF"; $server = "abc.com"; $fp = Fsockopen ($server, $errNo, $errStr, ten); Fputs ($FP, $text. "\ r \ n"); 100 Rows while (!feof ($fp)) {//101 line $data. = Fgets ($fp, 128);//102 line } fclose ($FP);
Is there any possibility that these lines of code will be modified?
------Solution--------------------
$fp = Fsockopen ($server, $errNo, $ERRSTR, 10);
Failed
The wrong code should be added
------Solution--------------------
Fsockopen didn't even open abc.com.
------Solution--------------------
Fsockopen () Returns a file pointer which may is used together with the other file functions (such as fgets (), FGETSS (), FW Rite (), fclose (), and feof ()). If The call fails, it'll return FALSE
So write = =
$data = "";
$text = "XAWASDF";
$server = "ABC.com";
$fp = Fsockopen ($server, $errNo, $ERRSTR, 10);
if ($FP)
{
Fputs ($FP, $text. "\ r \ n"); 100 rows
while (!feof ($fp)) {//101 row
$data. = Fgets ($fp, 128); 102 rows
}
Fclose ($FP);
}
------Solution--------------------
You fputs argument to an empty handle because fopen failure causes the returned content (fputs parameter) to be abnormal