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:
cslawi 1999-09-21 21:45:16 +00:00
parent 1af9bafd9f
commit aa31c905f4
2 changed files with 115 additions and 1 deletions

View file

@ -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>

View file

@ -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>
&lt;?php
function list_array( $array ) {
while ( list( $key, $value ) = each( $array ) ) {
$str .= "&lt;b&gt;$key:&lt;/b&gt; $value&lt;br&gt;\n";
}
return $str;
}
echo "$HTTP_USER_AGENT&lt;hr&gt;\n";
$browser = get_browser();
echo list_array( (array) $browser );
?&gt;
</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)&lt;hr&gt;
&lt;b&gt;browser_name_pattern:&lt;/b&gt; Mozilla/4\.5.*&lt;br&gt;
&lt;b&gt;parent:&lt;/b&gt; Netscape 4.0&lt;br&gt;
&lt;b&gt;platform:&lt;/b&gt; Unknown&lt;br&gt;
&lt;b&gt;majorver:&lt;/b&gt; 4&lt;br&gt;
&lt;b&gt;minorver:&lt;/b&gt; 5&lt;br&gt;
&lt;b&gt;browser:&lt;/b&gt; Netscape&lt;br&gt;
&lt;b&gt;version:&lt;/b&gt; 4&lt;br&gt;
&lt;b&gt;frames:&lt;/b&gt; 1&lt;br&gt;
&lt;b&gt;tables:&lt;/b&gt; 1&lt;br&gt;
&lt;b&gt;cookies:&lt;/b&gt; 1&lt;br&gt;
&lt;b&gt;backgroundsounds:&lt;/b&gt; &lt;br&gt;
&lt;b&gt;vbscript:&lt;/b&gt; &lt;br&gt;
&lt;b&gt;javascript:&lt;/b&gt; 1&lt;br&gt;
&lt;b&gt;javaapplets:&lt;/b&gt; 1&lt;br&gt;
&lt;b&gt;activexcontrols:&lt;/b&gt; &lt;br&gt;
&lt;b&gt;beta:&lt;/b&gt; &lt;br&gt;
&lt;b&gt;crawler:&lt;/b&gt; &lt;br&gt;
&lt;b&gt;authenticodeupdate:&lt;/b&gt; &lt;br&gt;
&lt;b&gt;msn:&lt;/b&gt; &lt;br&gt;
</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>