<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = 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-sapi-name.php',
    1 => 'php_sapi_name',
    2 => 'Returns the type of interface between web server and PHP',
  ),
  'up' => 
  array (
    0 => 'ref.info.php',
    1 => 'PHP Options/Info Functions',
  ),
  'prev' => 
  array (
    0 => 'function.php-ini-scanned-files.php',
    1 => 'php_ini_scanned_files',
  ),
  'next' => 
  array (
    0 => 'function.php-uname.php',
    1 => 'php_uname',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/info/functions/php-sapi-name.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.php-sapi-name" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">php_sapi_name</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.1, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">php_sapi_name</span> &mdash; <span class="dc-title">Returns the type of interface between web server and PHP</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.php-sapi-name-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>php_sapi_name</strong></span>(): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="simpara">
   Returns a lowercase string that describes the type of interface
   (the Server API, SAPI) that PHP is using. For example, in CLI PHP this
   string will be &quot;cli&quot; whereas with Apache it may have several different
   values depending on the exact SAPI used. Possible values are listed
   below.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.php-sapi-name-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">This function has no parameters.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.php-sapi-name-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the interface type, as a lowercase string,  or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure.
  </p>
  <p class="para">
   Although not exhaustive, the possible return values include 
   <code class="literal">apache</code>, 
   <code class="literal">apache2handler</code>, 
   <code class="literal">cgi</code> (until PHP 5.3), 
   <code class="literal">cgi-fcgi</code>, <code class="literal">cli</code>, <code class="literal">cli-server</code>,
   <code class="literal">embed</code>, <code class="literal">fpm-fcgi</code>,
   <code class="literal">litespeed</code>, 
   <code class="literal">phpdbg</code>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.php-sapi-name-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>php_sapi_name()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     This example checks for the substring <code class="literal">cgi</code>
     because it may also be <code class="literal">cgi-fcgi</code>.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$sapi_type </span><span style="color: #007700">= </span><span style="color: #0000BB">php_sapi_name</span><span style="color: #007700">();<br />if (</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$sapi_type</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">'cgi'</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"You are using CGI PHP\n"</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">"You are not using CGI PHP\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.php-sapi-name-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <strong>An alternative approach</strong><br />
   <p class="para">
    The PHP constant <strong><code><a href="reserved.constants.php#constant.php-sapi">PHP_SAPI</a></code></strong> has the same value
    as <span class="function"><strong>php_sapi_name()</strong></span>.
   </p>
  </p></blockquote>
  <div class="tip"><strong class="tip">Tip</strong>
   <h1 class="title">A potential gotcha</h1>
   <p class="para">
    The defined <abbr title="Server Application Programming Interface">SAPI</abbr> may not be obvious, because for
    example instead of <code class="literal">apache</code> it may be defined as 
    <code class="literal">apache2handler</code>.
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.php-sapi-name-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="reserved.constants.php#reserved.constants.core" class="link">PHP_SAPI</a></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>