Is there any way to throw an exception when fwrite can not write?

4

I use the SplFileObject class to work with files. The same does not occur with the sockets, when necessary to connect, being necessary to use the function fsockopen or stream_socket_client .

I need a code snippet in case a fwrite can not write the data, throw an exception.

Is there any way to do this?

    
asked by anonymous 22.10.2015 / 15:41

1 answer

2

I could do something like this:

> $resultado = fwrite('log.txt'); 
> if (false === $resultado) 
> {
>   throw new RuntimeException('Erro Especifico'); 
> }
    
22.06.2016 / 19:08