Returns an array not object, made docs register_globals = off friendly,

made example a little more friendly, linked directly to the offsite up-to-date
browscap.ini instead of faq, other minor changes, and added a <note> to clear
up what cookies means.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@109341 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2002-12-30 04:57:52 +00:00
parent 8f512efcad
commit 0da1ec65ad

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/misc.xml, last change in rev 1.2 -->
<refentry id="function.get-browser">
<refnamediv>
@ -11,21 +11,21 @@
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>object</type><methodname>get_browser</methodname>
<type>array</type><methodname>get_browser</methodname>
<methodparam choice="opt"><type>string</type><parameter>user_agent</parameter></methodparam>
</methodsynopsis>
<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
$HTTP_USER_AGENT is used; however, you can alter this (i.e., look
up another browser's info) by passing the optional
the browser's information in the <filename>browscap.ini</filename>
file. By default, the value of <varname>HTTP_USER_AGENT</varname> 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
The information is returned in an array, 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
@ -44,15 +44,14 @@
<programlisting role="php">
<![CDATA[
<?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";
echo $_SERVER['HTTP_USER_AGENT'] . "<hr />\n";
$browser = get_browser();
echo list_array ((array) $browser);
foreach ($browser as $name => $value) {
print "<b>$name</b> $value <br />\n";
}
?>
]]>
</programlisting>
@ -66,7 +65,7 @@ echo list_array ((array) $browser);
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>platform:</b> Linux<br />
<b>majorver:</b> 4<br />
<b>minorver:</b> 5<br />
<b>browser:</b> Netscape<br />
@ -87,16 +86,22 @@ Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr />
</programlisting>
<simpara>
In order for this to work, your <link
linkend="ini.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;">&url.php.faq;</ulink>.
linkend="ini.browscap">browscap</link> configuration setting in
&php.ini; must point to the correct location of the
<filename>browscap.ini</filename> file on your system. An up-to-date
<filename>browscap.ini</filename> file can be located
<ulink url="&url.browscap.download;">here</ulink>. By default, this
<link linkend="ini.browscap">browscap</link> directive is commented out.
</simpara>
<note>
<simpara>
The <literal>cookies</literal> value simply means that the browser
itself is capable of accepting cookies and does not mean the user has
enabled the browser to accept cookies or not. The only way to test if
cookies are accepted is to set one with <function>setcookie</function>,
reload, and check for the value.
</simpara>
</note>
</refsect1>
</refentry>