php-doc-en/reference/info/functions/php-sapi-name.xml
Sergey Panteleev 8dd14a886c
Fix issues in Info directory
Part of #658
2021-06-10 12:38:11 +03:00

119 lines
3.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.php-sapi-name" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>php_sapi_name</refname>
<refpurpose>Returns the type of interface between web server and PHP</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>string</type><type>false</type></type><methodname>php_sapi_name</methodname>
<void/>
</methodsynopsis>
<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 "cli" whereas with Apache it may have several different
values depending on the exact SAPI used. Possible values are listed
below.
</simpara>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the interface type, as a lowercase string, &return.falseforfailure;.
</para>
<para>
Although not exhaustive, the possible return values include
<literal>apache</literal>,
<literal>apache2handler</literal>,
<literal>cgi</literal> (until PHP 5.3),
<literal>cgi-fcgi</literal>, <literal>cli</literal>, <literal>cli-server</literal>,
<literal>embed</literal>, <literal>fpm-fcgi</literal>,
<literal>litespeed</literal>,
<literal>phpdbg</literal>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>php_sapi_name</function> example</title>
<para>
This example checks for the substring <literal>cgi</literal>
because it may also be <literal>cgi-fcgi</literal>.
</para>
<programlisting role="php">
<![CDATA[
<?php
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "You are using CGI PHP\n";
} else {
echo "You are not using CGI PHP\n";
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<title>An alternative approach</title>
<para>
The PHP constant <constant>PHP_SAPI</constant> has the same value
as <function>php_sapi_name</function>.
</para>
</note>
<tip>
<title>A potential gotcha</title>
<para>
The defined <acronym>SAPI</acronym> may not be obvious, because for
example instead of <literal>apache</literal> it may be defined as
<literal>apache2handler</literal>.
</para>
</tip>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><link linkend="reserved.constants.core">PHP_SAPI</link></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->