socket_bind
Function • Params and return types changed in PHP 8.0
Binds a name to a socket.
socket_bind Function synopsis
socket_bind(
Socket $socket,
string $address,
int $port = 0
): bool
Parameters
$socket
TypeSocket
A Socket instance created with socket_create.
$address
Typestring
If the socket is of the AF_INET family, the
$address is an IP in dotted-quad notation
(e.g. 127.0.0.1).
$port
OptionalTypeintDefault value0
The $port parameter is only used when
binding an AF_INET socket, and designates
the port on which to listen for connections.
Return value
Typebool
Returns true on success, false on failure
The error code can be retrieved with socket_last_error.
This code may be passed to socket_strerror to get a
textual explanation of the error.
Changes to the socket_bind Function
PHP 8.0
- Return type added:
bool - Parameter type added for parameter #1 (
$socket):Socket - Parameter name of parameter #2 changed:
$addrto$address - Parameter type added for parameter #2 (
$address):string - Parameter type added for parameter #3 (
$port):int - Parameter default value added for position #3 (
$port):0
socket_bind(
- $socket,
+ Socket $socket,
- $addr,
+ string $address,
- $port
+ int $port = 0
- )
+ ): bool socket_bind Function Availability
socket_bind Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |