Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5364

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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 the type of interface between web server and PHP</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.php-logo-guid.html">php_logo_guid</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.php-uname.html">php_uname</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-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)</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="type">string</span> <span class="methodname"><strong>php_sapi_name</strong></span>
    ( <span class="methodparam">void</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 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.
  </p>
  <p class="para">
   Although not exhaustive, the possible return values include 
   <em>aolserver</em>, <em>apache</em>, 
   <em>apache2filter</em>, <em>apache2handler</em>, 
   <em>caudium</em>, <em>cgi</em> (until PHP 5.3), 
   <em>cgi-fcgi</em>, <em>cli</em>, 
   <em>continuity</em>, <em>embed</em>,
   <em>isapi</em>, <em>litespeed</em>, 
   <em>milter</em>, <em>nsapi</em>, 
   <em>phttpd</em>, <em>pi3web</em>, <em>roxen</em>,
   <em>thttpd</em>, <em>tux</em>, and <em>webjames</em>.
  </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-508">
    <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 <em>cgi</em>
     because it may also be <em>cgi-fcgi</em>.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$sapi_type&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">php_sapi_name</span><span style="color: #007700">();<br />if&nbsp;(</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$sapi_type</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">'cgi'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"You&nbsp;are&nbsp;using&nbsp;CGI&nbsp;PHP\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"You&nbsp;are&nbsp;not&nbsp;using&nbsp;CGI&nbsp;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>PHP_SAPI</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 <acronym title="Server Application Programming Interface">SAPI</acronym> may not be obvious, because for
    example instead of <em>apache</em> it may be defined as 
    <em>apache2handler</em> or <em>apache2filter</em>.
   </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 class="member"><a href="reserved.constants.html#reserved.constants.core" class="link">PHP_SAPI</a></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-logo-guid.html">php_logo_guid</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.php-uname.html">php_uname</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>