The section about Process Control Functions maybe of interest for you.

posix_access

Determine accessibility of a file

说明

bool posix_access ( string $file [, int $mode = POSIX_F_OK ] )

posix_access checks the user's permission of a file.

参数

file
The name of the file to be tested.

mode
A mask consisting of one or more of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK and POSIX_X_OK.

POSIX_R_OK, POSIX_W_OK and POSIX_X_OK request checking whether the file exists and has read, write and execute permissions, respectively. POSIX_F_OK just requests checking for the existence of the file.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 posix_access example

This example will check if the $file is readable and writable, otherwise will print an error message.

<?php

$file = 'some_file';

if (posix_access($file, POSIX_R_OK | POSIX_W_OK)) {
    echo 'The file is readable and writable!';

} else {
    $error = posix_get_last_error();

    echo "Error $error: " . posix_strerror($error);
}

?>

注释

Note: 当启用 安全模式时, PHP 会检查被操作的文件或目录是否与被执行的脚本有相同的 UID(所有者)。

参见

  • posix_get_last_error
  • posix_strerror

posix_ctermid

Get path name of controlling terminal

说明

string posix_ctermid ( void )

Generates a string which is the pathname for the current controlling terminal for the process. On error this will set errno, which can be checked using posix_get_last_error

返回值

Upon successful completion, returns string of the pathname to the current controlling terminal. Otherwise FALSE is returned and errno is set, which can be checked with posix_get_last_error.

范例

示例 #1 posix_ctermid example

This example will display the path to the current TTY.

<?php
echo "I am running from ".posix_ctermid();
?>

参见

  • posix_ttyname
  • posix_get_last_error

posix_errno

别名 posix_get_last_error

说明

此函数是该函数的别名: posix_get_last_error.

posix_get_last_error

Retrieve the error number set by the last posix function that failed

说明

int posix_get_last_error ( void )

Retrieve the error number set by the last posix function that failed. The system error message associated with the errno may be checked with posix_strerror.

返回值

Returns the errno (error number) set by the last posix function that failed. If no errors exist, 0 is returned.

范例

示例 #1 posix_get_last_error example

This example attempt to kill a bogus process id, which will set the last error. We will then print out the last errno.

<?php
posix_kill(999459,SIGKILL);
echo 'Your error returned was '.posix_get_last_error(); //Your error was ___
?>

参见

  • posix_strerror

posix_getcwd

Pathname of current directory

说明

string posix_getcwd ( void )

Gets the absolute pathname of the script's current working directory. On error, it sets errno which can be checked using posix_get_last_error

返回值

Returns a string of the absolute pathname on success. On error, returns FALSE and sets errno which can be checked with posix_get_last_error.

范例

示例 #1 posix_getcwd example

This example will return the absolute path of the current working directory of the script.

<?php
echo 'My current working directory is '.posix_getcwd();
?>

注释

Note:

This function can fail on

  • Read or Search permission was denied
  • Pathname no longer exists

posix_getegid

Return the effective group ID of the current process

说明

int posix_getegid ( void )

Return the numeric effective group ID of the current process.

返回值

Returns an integer of the effective group ID.

范例

示例 #1 posix_getegid example

This example will print out the effective group id, once it is changed with posix_setegid.

<?php
echo 'My real group id is '.posix_getgid(); //20
posix_setegid(40);
echo 'My real group id is '.posix_getgid(); //20
echo 'My effective group id is '.posix_getegid(); //40
?>

注释

posix_getegid is different than posix_getgid because effective group ID can be changed by a calling process using posix_setegid.

参见

  • posix_getgrgid
  • posix_getgid
  • posix_setgid

posix_geteuid

Return the effective user ID of the current process

说明

int posix_geteuid ( void )

Return the numeric effective user ID of the current process. See also posix_getpwuid for information on how to convert this into a useable username.

返回值

Returns the user id, as an integer

范例

示例 #1 posix_geteuid example

This example will show the current user id then set the effective user id to a separate id using posix_seteuid, then show the difference between the real id and the effective id.

<?php
echo posix_getuid()."\n"; //10001
echo posix_geteuid()."\n"; //10001
posix_seteuid(10000);
echo posix_getuid()."\n"; //10001
echo posix_geteuid()."\n"; //10000
?>

参见

  • posix_getpwuid
  • posix_getuid
  • posix_setuid
  • POSIX man page GETEUID(2)

posix_getgid

Return the real group ID of the current process

说明

int posix_getgid ( void )

Return the numeric real group ID of the current process.

返回值

Returns the real group id, as an integer.

范例

示例 #1 posix_getgid example

This example will print out the real group id, even once the effective group id has been changed.

<?php
echo 'My real group id is '.posix_getgid(); //20
posix_setegid(40);
echo 'My real group id is '.posix_getgid(); //20
echo 'My effective group id is '.posix_getegid(); //40
?>

参见

  • posix_getgrgid
  • posix_getegid
  • posix_setgid
  • POSIX man page GETGID(2)

posix_getgrgid

Return info about a group by group id

说明

array posix_getgrgid ( int $gid )

Gets information about a group provided its id.

参数

gid
The group id.

返回值

The array elements returned are:

ElementDescription
nameThe name element contains the name of the group. This is a short, usually less than 16 character "handle" of the group, not the real, full name.
passwdThe passwd element contains the group's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.
gidGroup ID, should be the same as the gid parameter used when calling the function, and hence redundant.
membersThis consists of an array of string's for all the members in the group.

范例

示例 #1 Example use of posix_getgrgid

<?php

$groupid   = posix_getegid();
$groupinfo = posix_getgrgid($groupid);

print_r($groupinfo);
?>

以上例程的输出类似于:

Array
(
    [name]    => toons
    [passwd]  => x
    [members] => Array
        (
            [0] => tom
            [1] => jerry
        )
    [gid]     => 42
)

参见

  • posix_getegid
  • posix_getgrnam
  • filegroup
  • stat
  • safe_mode_gid
  • POSIX man page GETGRNAM(3)

posix_getgrnam

Return info about a group by name

说明

array posix_getgrnam ( string $name )

Gets information about a group provided its name.

参数

name
The name of the group

返回值

Returns an array on success, 或者在失败时返回 FALSE. The array elements returned are:

ElementDescription
nameThe name element contains the name of the group. This is a short, usually less than 16 character "handle" of the group, not the real, full name. This should be the same as the name parameter used when calling the function, and hence redundant.
passwdThe passwd element contains the group's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.
gidGroup ID of the group in numeric form.
membersThis consists of an array of string's for all the members in the group.

范例

示例 #1 Example use of posix_getgrnam

<?php

$groupinfo = posix_getgrnam("toons");

print_r($groupinfo);
?>

以上例程的输出类似于:

Array
(
    [name]    => toons
    [passwd]  => x
    [members] => Array
        (
            [0] => tom
            [1] => jerry
        )
    [gid]     => 42
)

参见

  • posix_getegid
  • posix_getgrgid
  • filegroup
  • stat
  • safe_mode_gid
  • POSIX man page GETGRNAM(3)

posix_getgroups

Return the group set of the current process

说明

array posix_getgroups ( void )

Gets the group set of the current process.

返回值

Returns an array of integers containing the numeric group ids of the group set of the current process.

范例

示例 #1 Example use of posix_getgroups

<?php

$groups = posix_getgroups();

print_r($groups);
?>

以上例程的输出类似于:

Array
(
    [0] => 4
    [1] => 20
    [2] => 24
    [3] => 25
    [4] => 29
    [5] => 30
    [6] => 33
    [7] => 44
    [8] => 46
    [9] => 104
    [10] => 109
    [11] => 110
    [12] => 1000
)

参见

  • posix_getgrgid

posix_getlogin

Return login name

说明

string posix_getlogin ( void )

Returns the login name of the user owning the current process.

返回值

Returns the login name of the user, as a string.

范例

示例 #1 Example use of posix_getlogin

<?php
echo posix_getlogin(); //apache
?>

参见

  • posix_getpwnam
  • POSIX man page GETLOGIN(3)

posix_getpgid

Get process group id for job control

说明

int posix_getpgid ( int $pid )

Returns the process group identifier of the process pid 或者在失败时返回 FALSE.

参数

pid
The process id.

返回值

Returns the identifier, as an integer.

范例

示例 #1 Example use of posix_getpgid

<?php
$pid = posix_getppid();
echo posix_getpgid($pid); //35
?>

注释

Note:

This is a not POSIX function, but is common on BSD and System V systems. If the system does not support this function, then it will not be included at compile time. This may be checked with class="function">function_exists.

参见

  • posix_getppid
  • man page SETPGID(2)

posix_getpgrp

Return the current process group identifier

说明

int posix_getpgrp ( void )

Return the process group identifier of the current process.

返回值

Returns the identifier, as an integer.

参见

  • POSIX.1 and the getpgrp(2) manual page on the POSIX system for more information on process groups.

posix_getpid

返回当前进程 id

说明

int posix_getpid ( void )

Return the process identifier of the current process. 返回当前进程的 id

返回值

返回进程 id 号,是整型(integer)。

范例

示例 #1 posix_getpid 的使用例子

<?php
echo posix_getpid(); //8805
?>

参见

  • posix_kill
  • POSIX man page GETPID(2)

posix_getppid

Return the parent process identifier

说明

int posix_getppid ( void )

Return the process identifier of the parent process of the current process.

返回值

Returns the identifier, as an integer.

范例

示例 #1 Example use of posix_getppid

<?php
echo posix_getppid(); //8259
?>

posix_getpwnam

Return info about a user by username

说明

array posix_getpwnam ( string $username )

Returns an array of information about the given user.

参数

username
An alphanumeric username.

返回值

On success an array with the following elements is returned, else FALSE is returned:

ElementDescription
nameThe name element contains the username of the user. This is a short, usually less than 16 character "handle" of the user, not the real, full name. This should be the same as the username parameter used when calling the function, and hence redundant.
passwdThe passwd element contains the user's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.
uidUser ID of the user in numeric form.
gidThe group ID of the user. Use the function posix_getgrgid to resolve the group name and a list of its members.
gecosGECOS is an obsolete term that refers to the finger information field on a Honeywell batch processing system. The field, however, lives on, and its contents have been formalized by POSIX. The field contains a comma separated list containing the user's full name, office phone, office number, and home phone number. On most systems, only the user's full name is available.
dirThis element contains the absolute path to the home directory of the user.
shellThe shell element contains the absolute path to the executable of the user's default shell.

范例

示例 #1 Example use of posix_getpwnam

<?php

$userinfo = posix_getpwnam("tom");

print_r($userinfo);
?>

以上例程的输出类似于:

Array
(
    [name]    => tom
    [passwd]  => x
    [uid]     => 10000
    [gid]     => 42
    [gecos]   => "tom,,,"
    [dir]     => "/home/tom"
    [shell]   => "/bin/bash"
)

参见

  • posix_getpwuid
  • POSIX man page GETPWNAM(3)

posix_getpwuid

Return info about a user by user id

说明

array posix_getpwuid ( int $uid )

Returns an array of information about the user referenced by the given user ID.

参数

uid
The user identifier.

返回值

Returns an associative array with the following elements:

ElementDescription
nameThe name element contains the username of the user. This is a short, usually less than 16 character "handle" of the user, not the real, full name.
passwdThe passwd element contains the user's password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.
uidUser ID, should be the same as the uid parameter used when calling the function, and hence redundant.
gidThe group ID of the user. Use the function posix_getgrgid to resolve the group name and a list of its members.
gecosGECOS is an obsolete term that refers to the finger information field on a Honeywell batch processing system. The field, however, lives on, and its contents have been formalized by POSIX. The field contains a comma separated list containing the user's full name, office phone, office number, and home phone number. On most systems, only the user's full name is available.
dirThis element contains the absolute path to the home directory of the user.
shellThe shell element contains the absolute path to the executable of the user's default shell.

范例

示例 #1 Example use of posix_getpwuid

<?php

$userinfo = posix_getpwuid(10000);

print_r($userinfo);
?>

以上例程的输出类似于:

Array
(
    [name]    => tom
    [passwd]  => x
    [uid]     => 10000
    [gid]     => 42
    [gecos]   => "tom,,,"
    [dir]     => "/home/tom"
    [shell]   => "/bin/bash"
)

参见

  • posix_getpwnam
  • POSIX man page GETPWNAM(3)

posix_getrlimit

Return info about system resource limits

说明

array posix_getrlimit ( void )

posix_getrlimit returns an array of information about the current resource's soft and hard limits.

Each resource has an associated soft and hard limit. The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit. An unprivileged process may only set its soft limit to a value from 0 to the hard limit, and irreversibly lower its hard limit.

返回值

Returns an associative array of elements for each limit that is defined. Each limit has a soft and a hard limit.

Limit nameLimit description
coreThe maximum size of the core file. When 0, not core files are created. When core files are larger than this size, they will be truncated at this size.
totalmemThe maximum size of the memory of the process, in bytes.
virtualmemThe maximum size of the virtual memory for the process, in bytes.
dataThe maximum size of the data segment for the process, in bytes.
stackThe maximum size of the process stack, in bytes.
rssThe maximum number of virtual pages resident in RAM
maxprocThe maximum number of processes that can be created for the real user ID of the calling process.
memlockThe maximum number of bytes of memory that may be locked into RAM.
cpuThe amount of time the process is allowed to use the CPU.
filesizeThe maximum size of the data segment for the process, in bytes.
openfilesOne more than the maximum number of open file descriptors.

范例

示例 #1 Example use of posix_getrlimit

<?php

$limits = posix_getrlimit();

print_r($limits);
?>

以上例程的输出类似于:

Array
(
    [soft core] => 0
    [hard core] => unlimited
    [soft data] => unlimited
    [hard data] => unlimited
    [soft stack] => 8388608
    [hard stack] => unlimited
    [soft totalmem] => unlimited
    [hard totalmem] => unlimited
    [soft rss] => unlimited
    [hard rss] => unlimited
    [soft maxproc] => unlimited
    [hard maxproc] => unlimited
    [soft memlock] => unlimited
    [hard memlock] => unlimited
    [soft cpu] => unlimited
    [hard cpu] => unlimited
    [soft filesize] => unlimited
    [hard filesize] => unlimited
    [soft openfiles] => 1024
    [hard openfiles] => 1024
)

参见

  • man page GETRLIMIT(2)
  • posix_setrlimit

posix_getsid

Get the current sid of the process

说明

int posix_getsid ( int $pid )

Return the session id of the process pid. The session id of a process is the process group id of the session leader.

参数

pid
The process identifier. If set to 0, the current process is assumed. If an invalid pid is specified, then FALSE is returned and an error is set which can be checked with posix_get_last_error.

返回值

Returns the identifier, as an integer.

范例

示例 #1 Example use of posix_getsid

<?php
$pid = posix_getpid();
echo posix_getsid($pid); //8805
?>

参见

  • posix_getpgid
  • posix_setsid
  • POSIX man page GETSID(2)

posix_getuid

Return the real user ID of the current process

说明

int posix_getuid ( void )

Return the numeric real user ID of the current process.

返回值

Returns the user id, as an integer

范例

示例 #1 Example use of posix_getuid

<?php
echo posix_getuid(); //10000
?>

参见

  • posix_getpwuid
  • POSIX man page GETUID(2)

posix_initgroups

Calculate the group access list

说明

bool posix_initgroups ( string $name , int $base_group_id )

Calculates the group access list for the user specified in name.

参数

name
The user to calculate the list for.

base_group_id
Typically the group number from the password file.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • The Unix manual page for initgroups(3).

posix_isatty

Determine if a file descriptor is an interactive terminal

说明

bool posix_isatty ( mixed $fd )

Determines if the file descriptor fd refers to a valid terminal type device.

参数

fd
The file descriptor, which is expected to be either a file resource or an integer. An integer will be assumed to be a file descriptor that can be passed directly to the underlying system call.

In almost all cases, you will want to provide a file resource.

返回值

Returns TRUE if fd is an open descriptor connected to a terminal and FALSE otherwise.

参见

  • posix_ttyname
  • stream_isatty

posix_kill

Send a signal to a process

说明

bool posix_kill ( int $pid , int $sig )

Send the signal sig to the process with the process identifier pid.

参数

pid
The process identifier.

sig
One of the PCNTL signals constants.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • The kill(2) manual page of the POSIX system, which contains additional information about negative process identifiers, the special pid 0, the special pid -1, and the signal number 0.

posix_mkfifo

Create a fifo special file (a named pipe)

说明

bool posix_mkfifo ( string $pathname , int $mode )

posix_mkfifo creates a special FIFO file which exists in the file system and acts as a bidirectional communication endpoint for processes.

参数

pathname
Path to the FIFO file.

mode
The second parameter mode has to be given in octal notation (e.g. 0644). The permission of the newly created FIFO also depends on the setting of the current umask. The permissions of the created file are (mode & ~umask).

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

注释

Note: 当启用 安全模式时, PHP 会检查被操作的文件或目录是否与被执行的脚本有相同的 UID(所有者)。

posix_mknod

Create a special or ordinary file (POSIX.1)

说明

bool posix_mknod ( string $pathname , int $mode [, int $major = 0 [, int $minor = 0 ]] )

Creates a special or ordinary file.

参数

pathname
The file to create

mode
This parameter is constructed by a bitwise OR between file type (one of the following constants: POSIX_S_IFREG, POSIX_S_IFCHR, POSIX_S_IFBLK, POSIX_S_IFIFO or POSIX_S_IFSOCK) and permissions.

major
The major device kernel identifier (required to pass when using S_IFCHR or S_IFBLK).

minor
The minor device kernel identifier.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 A posix_mknod example

<?php

$file = '/tmp/tmpfile';  // file name
$type = POSIX_S_IFBLK;   // file type
$permissions = 0777;     // octal
$major = 1;
$minor = 8;              // /dev/random

if (!posix_mknod($file, $type | $permissions, $major, $minor)) {
    die('Error ' . posix_get_last_error() . ': ' . posix_strerror(posix_get_last_error()));
}

?>

参见

  • posix_mkfifo

posix_setegid

Set the effective GID of the current process

说明

bool posix_setegid ( int $gid )

Set the effective group ID of the current process. This is a privileged function and needs appropriate privileges (usually root) on the system to be able to perform this function.

参数

gid
The group id.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 posix_setegid example

This example will print out the effective group id, once changed.

<?php
echo 'My real group id is '.posix_getgid(); //20
posix_setegid(40);
echo 'My real group id is '.posix_getgid(); //20
echo 'My effective group id is '.posix_getegid(); //40
?>

参见

  • posix_getgrgid
  • posix_getgid
  • posix_setgid

posix_seteuid

Set the effective UID of the current process

说明

bool posix_seteuid ( int $uid )

Set the effective user ID of the current process. This is a privileged function and needs appropriate privileges (usually root) on the system to be able to perform this function.

参数

uid
The user id.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • posix_geteuid
  • posix_setuid
  • posix_getuid

posix_setgid

Set the GID of the current process

说明

bool posix_setgid ( int $gid )

Set the real group ID of the current process. This is a privileged function and needs appropriate privileges (usually root) on the system to be able to perform this function. The appropriate order of function calls is posix_setgid first, posix_setuid last.

Note:

If the caller is a super user, this will also set the effective group id.

参数

gid
The group id.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 posix_setgid example

This example will print out the effective group id, once it is changed.

<?php
echo 'My real group id is '.posix_getgid(); //20
posix_setgid(40);
echo 'My real group id is '.posix_getgid(); //40
echo 'My effective group id is '.posix_getegid(); //40
?>

参见

  • posix_getgrgid
  • posix_getgid

posix_setpgid

Set process group id for job control

说明

bool posix_setpgid ( int $pid , int $pgid )

Let the process pid join the process group pgid.

参数

pid
The process id.

pgid
The process group id.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • See POSIX.1 and the setsid(2) manual page on the POSIX system for more information on process groups and job control.

posix_setrlimit

Set system resource limits

说明

bool posix_setrlimit ( int $resource , int $softlimit , int $hardlimit )

posix_setrlimit sets the soft and hard limits for a given system resource.

Each resource has an associated soft and hard limit. The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit. An unprivileged process may only set its soft limit to a value from 0 to the hard limit, and irreversibly lower its hard limit.

参数

resource
The resource limit constant corresponding to the limit that is being set.

softlimit
The soft limit, in whatever unit the resource limit requires, or POSIX_RLIMIT_INFINITY.

hardlimit
The hard limit, in whatever unit the resource limit requires, or POSIX_RLIMIT_INFINITY.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • man page SETRLIMIT(2)
  • posix_getrlimit

posix_setsid

Make the current process a session leader

说明

int posix_setsid ( void )

Make the current process a session leader.

返回值

Returns the session id, or -1 on errors.

参见

  • The POSIX.1 and the setsid(2) manual page on the POSIX system for more information on process groups and job control.

posix_setuid

Set the UID of the current process

说明

bool posix_setuid ( int $uid )

Set the real user ID of the current process. This is a privileged function that needs appropriate privileges (usually root) on the system to be able to perform this function.

参数

uid
The user id.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 posix_setuid example

This example will show the current user id and then set it to a different value.

<?php
echo posix_getuid()."\n"; //10001
echo posix_geteuid()."\n"; //10001
posix_setuid(10000);
echo posix_getuid()."\n"; //10000
echo posix_geteuid()."\n"; //10000
?>

参见

  • posix_setgid
  • posix_seteuid
  • posix_getuid
  • posix_geteuid

posix_strerror

Retrieve the system error message associated with the given errno

说明

string posix_strerror ( int $errno )

Returns the POSIX system error message associated with the given errno. You may get the errno parameter by calling posix_get_last_error.

参数

errno
A POSIX error number, returned by posix_get_last_error. If set to 0, then the string "Success" is returned.

返回值

Returns the error message, as a string.

范例

示例 #1 posix_strerror example

This example will attempt to kill a process which does not exist, then will print out the corresponding error message.

<?php
posix_kill(50,SIGKILL);
echo posix_strerror(posix_get_last_error())."\n";
?>

以上例程的输出类似于:

No such process

参见

  • posix_get_last_error

posix_times

Get process times

说明

array posix_times ( void )

Gets information about the current CPU usage.

返回值

Returns a hash of strings with information about the current process CPU usage. The indices of the hash are:

  • ticks - the number of clock ticks that have elapsed since reboot.
  • utime - user time used by the current process.
  • stime - system time used by the current process.
  • cutime - user time used by current process and children.
  • cstime - system time used by current process and children.

注释

Warning

This function isn't reliable to use, it may return negative values for high times.

范例

示例 #1 Example use of posix_times

<?php

$times = posix_times();

print_r($times);
?>

以上例程的输出类似于:

Array
(
    [ticks] => 25814410
    [utime] => 1
    [stime] => 1
    [cutime] => 0
    [cstime] => 0
)

posix_ttyname

Determine terminal device name

说明

string posix_ttyname ( mixed $fd )

Returns a string for the absolute path to the current terminal device that is open on the file descriptor fd.

参数

fd
The file descriptor, which is expected to be either a file resource or an integer. An integer will be assumed to be a file descriptor that can be passed directly to the underlying system call.

In almost all cases, you will want to provide a file resource.

返回值

On success, returns a string of the absolute path of the fd. On failure, returns FALSE

posix_uname

Get system name

说明

array posix_uname ( void )

Gets information about the system.

Posix requires that assumptions must not be made about the format of the values, e.g. the assumption that a release may contain three digits or anything else returned by this function.

返回值

Returns a hash of strings with information about the system. The indices of the hash are

  • sysname - operating system name (e.g. Linux)
  • nodename - system name (e.g. valiant)
  • release - operating system release (e.g. 2.2.10)
  • version - operating system version (e.g. #4 Tue Jul 20 17:01:36 MEST 1999)
  • machine - system architecture (e.g. i586)
  • domainname - DNS domainname (e.g. example.com)

domainname is a GNU extension and not part of POSIX.1, so this field is only available on GNU systems or when using the GNU libc.

范例

示例 #1 Example use of posix_uname

<?php
$uname=posix_uname();
print_r($uname);
?>

以上例程的输出类似于:

Array
(
    [sysname] => Linux
    [nodename] => funbox
    [release] => 2.6.20-15-server
    [version] => #2 SMP Sun Apr 15 07:41:34 UTC 2007
    [machine] => i686
)

目录