- stream_socket_client: documentation ( source)
- set_error_handler: documentation ( source)
<?php
set_error_handler(function (int $severity, string $message, string $file, int $line) {
throw new ErrorException($message, $severity, $severity, $file, $line);
});
if (!$resource = @stream_socket_client('tcp://123.456.789', $errno, $errstr)) {
throw new Exception($errstr);
}