yp_all

Traverse the map and call a function on each entry

说明

void yp_all ( string $domain , string $map , string $callback )

Warning

本函数还未编写文档,仅有参数列表。

参数

domain
The NIS domain name.

map
The NIS map.

callback

返回值

没有返回值。

yp_cat

Return an array containing the entire map

说明

array yp_cat ( string $domain , string $map )

Returns all map entries.

参数

domain
The NIS domain name.

map
The NIS map.

返回值

Returns an array of all map entries, the maps key values as array indices and the maps entries as array data.

yp_err_string

Returns the error string associated with the given error code

说明

string yp_err_string ( int $errorcode )

Returns the error message associated with the given error code. Useful to indicate what exactly went wrong.

参数

errorcode
The error code.

返回值

Returns the error message, as a string.

范例

示例 #1 Example for NIS errors

<?php
echo "Error: " . yp_err_string(yp_errno());
?>

参见

  • yp_errno

yp_errno

Returns the error code of the previous operation

说明

int yp_errno ( void )

Returns the error code of the previous operation.

返回值

Returns one of the YPERR_XXX error constants.

参见

  • yp_err_string

yp_first

Returns the first key-value pair from the named map

说明

array yp_first ( string $domain , string $map )

Gets the first key-value pair from the named map in the named domain.

参数

domain
The NIS domain name.

map
The NIS map.

返回值

Returns the first key-value pair as an array on success, or FALSE on errors.

范例

示例 #1 Example for the NIS first

<?php
$entry = yp_first($domain, "passwd.byname");

$key = key($entry);
$value = $entry[$key];

echo "First entry in this map has key " . $key . " and value " . $value;
?>

参见

  • yp_next
  • yp_get_default_domain

yp_get_default_domain

Fetches the machine's default NIS domain

说明

string yp_get_default_domain ( void )

Returns the default domain of the node. Can be used as the domain parameter for successive NIS calls.

A NIS domain can be described a group of NIS maps. Every host that needs to look up information binds itself to a certain domain. Refer to the documents mentioned at the beginning for more detailed information.

返回值

Returns the default domain of the node or FALSE. Can be used as the domain parameter for successive NIS calls.

范例

示例 #1 Example for the default domain

<?php
$domain = yp_get_default_domain();
echo "Default NIS domain is: " . $domain;
?>

yp_master

Returns the machine name of the master NIS server for a map

说明

string yp_master ( string $domain , string $map )

Returns the machine name of the master NIS server for a map.

参数

domain
The NIS domain name.

map
The NIS map.

返回值

范例

示例 #1 Example for the NIS master

<?php
$number = yp_master($domain, $mapname);
echo "Master for this map is: " . $master;
?>

参见

  • yp_get_default_domain

yp_match

Returns the matched line

说明

string yp_match ( string $domain , string $map , string $key )

Returns the value associated with the passed key out of the specified map.

参数

domain
The NIS domain name.

map
The NIS map.

key
This key must be exact.

返回值

Returns the value, or FALSE on errors.

范例

示例 #1 Example for NIS match

<?php
$entry = yp_match($domain, "passwd.byname", "joe");
echo "Matched entry is: " . $entry;
?>

以上例程的输出类似于:

joe:##joe:11111:100:Joe User:/home/j/joe:/usr/local/bin/bash

参见

  • yp_get_default_domain

yp_next

Returns the next key-value pair in the named map

说明

array yp_next ( string $domain , string $map , string $key )

Returns the next key-value pair in the named map after the specified key.

参数

domain

map

key

返回值

Returns the next key-value pair as an array, or FALSE on errors.

范例

示例 #1 Example for NIS next

<?php
$entry = yp_next($domain, "passwd.byname", "joe");

if (!$entry) {
    echo "No more entries found\n";
    echo "<!--" . yp_errno() . ": " . yp_err_string() . "-->";
}

$key = key($entry);

echo "The next entry after joe has key " . $key
      . " and value " . $entry[$key];
?>

参见

  • yp_first
  • yp_get_default_domain

yp_order

Returns the order number for a map

说明

int yp_order ( string $domain , string $map )

Gets the order number for a map.

参数

domain

map

返回值

Returns the order number for a map or FALSE on error.

范例

示例 #1 Example for the NIS order

<?php
    $number = yp_order($domain, $mapname);
    echo "Order number for this map is: " . $number;
?>

参见

  • yp_get_default_domain

目录

  • yp_all — Traverse the map and call a function on each entry
  • yp_cat — Return an array containing the entire map
  • yp_err_string — Returns the error string associated with the given error code
  • yp_errno — Returns the error code of the previous operation
  • yp_first — Returns the first key-value pair from the named map
  • yp_get_default_domain — Fetches the machine's default NIS domain
  • yp_master — Returns the machine name of the master NIS server for a map
  • yp_match — Returns the matched line
  • yp_next — Returns the next key-value pair in the named map
  • yp_order — Returns the order number for a map