mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Documented get_browser().
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@13437 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
1af9bafd9f
commit
aa31c905f4
2 changed files with 115 additions and 1 deletions
|
@ -1247,7 +1247,8 @@ include_path=".;c:\www\phplib"
|
|||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Name of browser capabilities file.
|
||||
Name of browser capabilities file. See also
|
||||
<function>get_browser</function>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -286,6 +286,119 @@ This is a cup with my coffee in it.
|
|||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
||||
<refentry id="function.get-browser">
|
||||
<refnamediv>
|
||||
<refname>get_browser</refname>
|
||||
<refpurpose>Tells what the user's browser is capable of.</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcdef>object <function>get_browser</function></funcdef>
|
||||
<paramdef>string <parameter><optional>user_agent</optional></parameter></paramdef>
|
||||
</funcsynopsis>
|
||||
|
||||
<simpara>
|
||||
<function>get_browser</function> attempts to determine the
|
||||
capabilities of the user's browser. This is done by looking up
|
||||
the browser's information in the
|
||||
<filename>browscap.ini</filename> file. By default, the value of
|
||||
<variable>$HTTP_USER_AGENT</variable> is used; however, you can
|
||||
alter this (i.e., look up another browser's info) by passing the
|
||||
optional <parameter>user_agent</parameter> parameter to
|
||||
<function>get_browser</function>.
|
||||
</simpara>
|
||||
|
||||
<simpara>
|
||||
The information is returned in an object, which will contain
|
||||
various data elements representing, for instance, the browser's
|
||||
major and minor version numbers and ID string;
|
||||
true/false values for features such as frames, JavaScript, and
|
||||
cookies; and so forth.
|
||||
</simpara>
|
||||
|
||||
<simpara>
|
||||
While <filename>browscap.ini</filename> contains information on
|
||||
many browsers, it relies on user updates to keep the database
|
||||
current. The format of the file is fairly self-explanatory.
|
||||
</simpara>
|
||||
|
||||
<para>
|
||||
The following example shows how one might list all available
|
||||
information retrieved about the user's browser.
|
||||
|
||||
<example>
|
||||
<title><function>get_browser</function> example</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
function list_array( $array ) {
|
||||
while ( list( $key, $value ) = each( $array ) ) {
|
||||
$str .= "<b>$key:</b> $value<br>\n";
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
echo "$HTTP_USER_AGENT<hr>\n";
|
||||
$browser = get_browser();
|
||||
echo list_array( (array) $browser );
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
||||
<simpara>
|
||||
The output of the above script would look something like this:
|
||||
</simpara>
|
||||
|
||||
<simpara>
|
||||
<programlisting>
|
||||
Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr>
|
||||
<b>browser_name_pattern:</b> Mozilla/4\.5.*<br>
|
||||
<b>parent:</b> Netscape 4.0<br>
|
||||
<b>platform:</b> Unknown<br>
|
||||
<b>majorver:</b> 4<br>
|
||||
<b>minorver:</b> 5<br>
|
||||
<b>browser:</b> Netscape<br>
|
||||
<b>version:</b> 4<br>
|
||||
<b>frames:</b> 1<br>
|
||||
<b>tables:</b> 1<br>
|
||||
<b>cookies:</b> 1<br>
|
||||
<b>backgroundsounds:</b> <br>
|
||||
<b>vbscript:</b> <br>
|
||||
<b>javascript:</b> 1<br>
|
||||
<b>javaapplets:</b> 1<br>
|
||||
<b>activexcontrols:</b> <br>
|
||||
<b>beta:</b> <br>
|
||||
<b>crawler:</b> <br>
|
||||
<b>authenticodeupdate:</b> <br>
|
||||
<b>msn:</b> <br>
|
||||
</programlisting>
|
||||
</simpara>
|
||||
|
||||
<simpara>
|
||||
In order for this to work, your <link
|
||||
linkend="ini.sect.browscap">browscap</link> configuration file
|
||||
setting must point to the correct location of the
|
||||
<filename>browscap.ini</filename> file.
|
||||
</simpara>
|
||||
|
||||
<simpara>
|
||||
For more information (including locations from which you may
|
||||
obtain a <filename>browscap.ini</filename> file), check the PHP
|
||||
FAQ at <ulink
|
||||
url="&url.php.faq;">http://www.php.net/FAQ.html</ulink>.
|
||||
</simpara>
|
||||
|
||||
<note>
|
||||
<simpara>
|
||||
browscap support was added to PHP in version 3.0b2.
|
||||
</simpara>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
||||
<refentry id="function.ignore-user-abort">
|
||||
<refnamediv>
|
||||
<refname>ignore_user_abort</refname>
|
||||
|
|
Loading…
Reference in a new issue