📄 function.posix-getpwnam.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Return info about a user by username</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.posix-getppid.html">posix_getppid</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.posix-getpwuid.html">posix_getpwuid</a></div> <div class="up"><a href="ref.posix.html">POSIX Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.posix-getpwnam" class="refentry"> <div class="refnamediv"> <h1 class="refname">posix_getpwnam</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">posix_getpwnam</span> — <span class="dc-title">Return info about a user by username</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>posix_getpwnam</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$username</tt></span> )</div> <p class="para rdfs-comment"> Returns an <a href="language.types.array.html" class="type array">array</a> of information about the given user. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">username</tt></i></span> <dd> <p class="para"> An alphanumeric username. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> On success an array with the following elements are returned, else <b><tt>FALSE</tt></b> is returned: <table border="5"> <caption><b>The user information array</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Element</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">name</td> <td colspan="1" rowspan="1" align="left"> The 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 <i><tt class="parameter">username</tt></i> parameter used when calling the function, and hence redundant. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">passwd</td> <td colspan="1" rowspan="1" align="left"> The 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. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">uid</td> <td colspan="1" rowspan="1" align="left"> User ID of the user in numeric form. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">gid</td> <td colspan="1" rowspan="1" align="left"> The group ID of the user. Use the function <a href="function.posix-getgrgid.html" class="function">posix_getgrgid()</a> to resolve the group name and a list of its members. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">gecos</td> <td colspan="1" rowspan="1" align="left"> GECOS 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. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">dir</td> <td colspan="1" rowspan="1" align="left"> This element contains the absolute path to the home directory of the user. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">shell</td> <td colspan="1" rowspan="1" align="left"> The shell element contains the absolute path to the executable of the user's default shell. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Example use of <b>posix_getpwnam()</b></b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br />$userinfo </span><span style="color: #007700">= </span><span style="color: #0000BB">posix_getpwnam</span><span style="color: #007700">(</span><span style="color: #DD0000">"tom"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$userinfo</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>Array( [name] => tom [passwd] => x [uid] => 10000 [gid] => 42 [geocs] => "tom,,," [dir] => "/home/tom" [shell] => "/bin/bash")</pre></div> </pre></div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.posix-getpwuid.html" class="function" rel="rdfs-seeAlso">posix_getpwuid()</a></li> <li class="member">POSIX man page GETPWNAM(3)</li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.posix-getppid.html">posix_getppid</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.posix-getpwuid.html">posix_getpwuid</a></div> <div class="up"><a href="ref.posix.html">POSIX Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -