downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.php-uname.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.info.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.php-uname.php',
   
1 => 'php_uname',
  ),
 
'up' =>
  array (
   
0 => 'ref.info.php',
   
1 => 'PHP Options/Info Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.php-sapi-name.php',
   
1 => 'php_sapi_name',
  ),
 
'next' =>
  array (
   
0 => 'function.phpcredits.php',
   
1 => 'phpcredits',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.php-uname" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">php_uname</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.2, PHP 5)</p><p class="refpurpose"><span class="refname">php_uname</span> &mdash; <span class="dc-title">Returns information about the operating system PHP is running on</span></p>

 </div>
 
 <a name="function.php-uname.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><b>php_uname</b></span>
    ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$mode</tt><span class="initializer"> = &quot;a&quot;</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   <b>php_uname()</b> returns a description of the operating
   system PHP is running on.  This is the same string you see at the very
   top of the <a href="function.phpinfo.php" class="function">phpinfo()</a> output.  For the name of just
   the operating system, consider using the <b><tt class="constant">PHP_OS</tt></b>
   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&#039;t exist or doesn&#039;t work.
  </p>
 </div>


 <a name="function.php-uname.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">mode</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       <i><tt class="parameter">mode</tt></i>
 is a single character that defines what
       information is returned:
       </p><ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          <i>&#039;a&#039;</i>: This is the default. Contains all modes in
          the sequence <i>&quot;s n r v m&quot;</i>.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <i>&#039;s&#039;</i>: Operating system name. eg.
           <i>FreeBSD</i>.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <i>&#039;n&#039;</i>: Host name. eg.
          <i>localhost.example.com</i>.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <i>&#039;r&#039;</i>: Release name. eg.
          <i>5.1.2-RELEASE</i>.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <i>&#039;v&#039;</i>: Version information. Varies a lot between
          operating systems.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <i>&#039;m&#039;</i>: Machine type. eg. <i>i386</i>.
         </span>
        </li>
       </ul><p>
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.php-uname.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the description, as a string.
  </p>
 </div>


 <a name="function.php-uname.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 Some <b>php_uname()</b> examples</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">php_uname</span><span style="color: #007700">();<br />echo&nbsp;</span><span style="color: #0000BB">PHP_OS</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/*&nbsp;Some&nbsp;possible&nbsp;outputs:<br />Linux&nbsp;localhost&nbsp;2.4.21-0.13mdk&nbsp;#1&nbsp;Fri&nbsp;Mar&nbsp;14&nbsp;15:08:06&nbsp;EST&nbsp;2003&nbsp;i686<br />Linux<br /><br />FreeBSD&nbsp;localhost&nbsp;3.2-RELEASE&nbsp;#15:&nbsp;Mon&nbsp;Dec&nbsp;17&nbsp;08:46:02&nbsp;GMT&nbsp;2001<br />FreeBSD<br /><br />Windows&nbsp;NT&nbsp;XN1&nbsp;5.1&nbsp;build&nbsp;2600<br />WINNT<br />*/<br /><br /></span><span style="color: #007700">if&nbsp;(</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">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">))&nbsp;===&nbsp;</span><span style="color: #DD0000">'WIN'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'This&nbsp;is&nbsp;a&nbsp;server&nbsp;using&nbsp;Windows!'</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'This&nbsp;is&nbsp;a&nbsp;server&nbsp;not&nbsp;using&nbsp;Windows!'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
  <p class="para">
   There are also some related <a href="language.constants.predefined.php" class="link">
   Predefined PHP constants</a> that may come in handy, for example:
   </p><div class="example">
    <p><b>Example #2 A few OS related constant examples</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;*nix<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">DIRECTORY_SEPARATOR</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;/<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">PHP_SHLIB_SUFFIX</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;so<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">PATH_SEPARATOR</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;:<br /><br />//&nbsp;Win*<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">DIRECTORY_SEPARATOR</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;\<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">PHP_SHLIB_SUFFIX</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;dll<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">PATH_SEPARATOR</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


 <a name="function.php-uname.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.phpversion.php" class="function" rel="rdfs-seeAlso">phpversion()</a> - Gets the current PHP version</li>
    <li class="member"><a href="function.php-sapi-name.php" class="function" rel="rdfs-seeAlso">php_sapi_name()</a> - Returns the type of interface between web server and PHP</li>
    <li class="member"><a href="function.phpinfo.php" class="function" rel="rdfs-seeAlso">phpinfo()</a> - Outputs lots of PHP information</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites