<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Returns information about the operating system PHP is running on</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.php-sapi-name.html">php_sapi_name</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.phpcredits.html">phpcredits</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.php-uname" class="refentry"> <div class="refnamediv"> <h1 class="refname">php_uname</h1> <p class="verinfo">(PHP 4 >= 4.0.2, PHP 5)</p><p class="refpurpose"><span class="refname">php_uname</span> — <span class="dc-title">Returns information about the operating system PHP is running on</span></p> </div> <div class="refsect1 description" id="refsect1-function.php-uname-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>php_uname</strong></span> ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$mode</code><span class="initializer"> = "a"</span></span> ] )</div> <p class="para rdfs-comment"> <span class="function"><strong>php_uname()</strong></span> returns a description of the operating system PHP is running on. This is the same string you see at the very top of the <span class="function"><a href="function.phpinfo.html" class="function">phpinfo()</a></span> output. For the name of just the operating system, consider using the <strong><code>PHP_OS</code></strong> constant, but keep in mind this constant will contain the operating system PHP was <em class="emphasis">built</em> on. </p> <p class="para"> On some older UNIX platforms, it may not be able to determine the current OS information in which case it will revert to displaying the OS PHP was built on. This will only happen if your uname() library call either doesn't exist or doesn't work. </p> </div> <div class="refsect1 parameters" id="refsect1-function.php-uname-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">mode</code></em></span> <dd> <p class="para"> <em><code class="parameter">mode</code></em> is a single character that defines what information is returned: <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <em>'a'</em>: This is the default. Contains all modes in the sequence <em>"s n r v m"</em>. </span> </li> <li class="listitem"> <span class="simpara"> <em>'s'</em>: Operating system name. eg. <em>FreeBSD</em>. </span> </li> <li class="listitem"> <span class="simpara"> <em>'n'</em>: Host name. eg. <em>localhost.example.com</em>. </span> </li> <li class="listitem"> <span class="simpara"> <em>'r'</em>: Release name. eg. <em>5.1.2-RELEASE</em>. </span> </li> <li class="listitem"> <span class="simpara"> <em>'v'</em>: Version information. Varies a lot between operating systems. </span> </li> <li class="listitem"> <span class="simpara"> <em>'m'</em>: Machine type. eg. <em>i386</em>. </span> </li> </ul> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.php-uname-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the description, as a string. </p> </div> <div class="refsect1 examples" id="refsect1-function.php-uname-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-509"> <p><strong>Example #1 Some <span class="function"><strong>php_uname()</strong></span> examples</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">php_uname</span><span style="color: #007700">();<br />echo </span><span style="color: #0000BB">PHP_OS</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Some possible outputs:<br />Linux localhost 2.4.21-0.13mdk #1 Fri Mar 14 15:08:06 EST 2003 i686<br />Linux<br /><br />FreeBSD localhost 3.2-RELEASE #15: Mon Dec 17 08:46:02 GMT 2001<br />FreeBSD<br /><br />Windows NT XN1 5.1 build 2600<br />WINNT<br />*/<br /><br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">strtoupper</span><span style="color: #007700">(</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">PHP_OS</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">)) === </span><span style="color: #DD0000">'WIN'</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">'This is a server using Windows!'</span><span style="color: #007700">;<br />} else {<br /> echo </span><span style="color: #DD0000">'This is a server not using Windows!'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> <p class="para"> There are also some related <a href="language.constants.predefined.html" class="link"> Predefined PHP constants</a> that may come in handy, for example: <div class="example" id="example-510"> <p><strong>Example #2 A few OS related constant examples</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// *nix<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">DIRECTORY_SEPARATOR</span><span style="color: #007700">; </span><span style="color: #FF8000">// /<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">PHP_SHLIB_SUFFIX</span><span style="color: #007700">; </span><span style="color: #FF8000">// so<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">PATH_SEPARATOR</span><span style="color: #007700">; </span><span style="color: #FF8000">// :<br /><br />// Win*<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">DIRECTORY_SEPARATOR</span><span style="color: #007700">; </span><span style="color: #FF8000">// \<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">PHP_SHLIB_SUFFIX</span><span style="color: #007700">; </span><span style="color: #FF8000">// dll<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">PATH_SEPARATOR</span><span style="color: #007700">; </span><span style="color: #FF8000">// ;<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.php-uname-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.phpversion.html" class="function" rel="rdfs-seeAlso">phpversion()</a> - Gets the current PHP version</span></li> <li class="member"> <span class="function"><a href="function.php-sapi-name.html" class="function" rel="rdfs-seeAlso">php_sapi_name()</a> - Returns the type of interface between web server and PHP</span></li> <li class="member"> <span class="function"><a href="function.phpinfo.html" class="function" rel="rdfs-seeAlso">phpinfo()</a> - Outputs information about PHP's configuration</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.php-sapi-name.html">php_sapi_name</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.phpcredits.html">phpcredits</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>