2024 PHP Conference Japan

getservbyport

(PHP 4, PHP 5, PHP 7, PHP 8)

getservbyport取得對應埠和協定的網際網路服務

說明

getservbyport(int $port, string $protocol): string|false

getservbyport() 會根據 /etc/services 傳回與指定 protocolport 相關聯的網際網路服務。

參數

port

埠號。

protocol

protocol"tcp""udp"(小寫)。

傳回值

傳回網際網路服務名稱字串,失敗時則傳回 false

參見

新增註記

使用者貢獻的註記 1 則註記

1
paland at stetson dot edu
24 年前
範例
<?php $value = getservbyport(137, "udp"); ?>

getservbyname() 的用法也相同
To Top