phpday 2027 - Call for Papers

socket_strerror

(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)

socket_strerror — Restituisce una stringa che descrive un errore del socket

Descrizione

function socket_strerror(int $error_code): string

socket_strerror() accetta come proprio parametro error_code un codice di errore del socket così come restituito da socket_last_error() e restituisce il corrispondente testo esplicativo.

Nota:

Sebbene i messaggi di errore generati dall'estensione socket siano in inglese, i messaggi di sistema recuperati con questa funzione appariranno in base alla localizzazione corrente (LC_MESSAGES).

Elenco dei parametri

error_code

Un numero di errore del socket valido, probabilmente prodotto da socket_last_error().

Valori restituiti

Restituisce il messaggio di errore associato al parametro error_code.

Esempi

Example #1 Esempio di socket_strerror()

<?php
if (false == ($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
   echo "socket_create() fallita: motivo: " . socket_strerror(socket_last_error()) . "\n";
}

if (false == (@socket_bind($socket, '127.0.0.1', 80))) {
   echo "socket_bind() fallita: motivo: " . socket_strerror(socket_last_error($socket)) . "\n";
}
?>

L'output previsto dall'esempio precedente (supponendo che lo script non venga eseguito con i privilegi di root):

socket_bind() fallita: motivo: Permission denied

Vedere anche:

User Contributed Notes

There are no user contributed notes for this page.
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top