by Example
Display the drop-down list
Configuration of getprotobyname()
<?php
/**
* PHP By Example
*
* @copyright 2014 Michel Corne
* @license http://www.opensource.org/licenses/gpl-3.0.html GNU GPL v3
*/
require_once 'models/function_core.php';
/**
* Function configuration
*
* @see docs/function-configuration.txt
*/
class getprotobyname extends function_core
{
public $examples = ["tcp"];
public $synopsis = 'int getprotobyname ( string $name )';
function _get_options_list()
{
// see http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
foreach (range(0, 255) as $number) {
if ($name = getprotobynumber($number)) {
$names[] = $name;
}
}
$options_list = isset($names) ? ['name' => $names] : [];
return $options_list;
}
}
Help
Misc
Config
Test
Unit test
Powered by
PHP 7.1.33 (0.01 s)
2014-2017 Michel Corne