I use fsockopen, fgets and fputs to implement communication protocol with other machine. NetBeans give warning to all '@' before fsockopen, fputs, fgets
etc. The solution works but without '@' after disconnection of remote device there are warnings (not errors).
I don't want to use error_reporting because it is not more kosher solution. Additionally more code, longer execution time...
Is there any better solution for this?
BTW. the warnings occurs if the destination machine will drop connection. It is possible if device is overload.
$answer=@fgets($socket, $negotiatedMaxLength);
BTW. The solution should work without ini_set
- blocked on server and without error_reporting()
.
One way instead of
@
which is obvious way to do it, is to useset_error_handler
https://www.w3schools.com/php/func_error_set_error_handler.asp
This lets you pipe the errors into the
ErrorException
class and then you have exceptions instead of errors. That's allows you to usetry/catch
blocks for the errors.Note the
&
single ampersand is intentional for checking severity level -vs- error reporting level you dobitwise And
Also the
$file
and$line
are optional, so we set a default for them.