From 0da1ec65ad0457fd379a47ed001aa184c89bb38b Mon Sep 17 00:00:00 2001 From: Philip Olson Date: Mon, 30 Dec 2002 04:57:52 +0000 Subject: [PATCH] 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 to clear up what cookies means. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@109341 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/misc/functions/get-browser.xml | 55 +++++++++++++----------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/reference/misc/functions/get-browser.xml b/reference/misc/functions/get-browser.xml index 7db087a5f3..dd2b188b1a 100644 --- a/reference/misc/functions/get-browser.xml +++ b/reference/misc/functions/get-browser.xml @@ -1,5 +1,5 @@ - + @@ -11,21 +11,21 @@ Description - objectget_browser + arrayget_browser stringuser_agent get_browser attempts to determine the capabilities of the user's browser. This is done by looking up - the browser's information in the - browscap.ini 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 browscap.ini + 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 user_agent parameter to get_browser. - 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 @@ $key: $value
\n"; - } - return $str; -} -echo "$HTTP_USER_AGENT
\n"; +echo $_SERVER['HTTP_USER_AGENT'] . "
\n"; + $browser = get_browser(); -echo list_array ((array) $browser); + +foreach ($browser as $name => $value) { + print "$name $value
\n"; +} + ?> ]]>
@@ -66,7 +65,7 @@ echo list_array ((array) $browser); Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)
browser_name_pattern: Mozilla/4\.5.*
parent: Netscape 4.0
-platform: Unknown
+platform: Linux
majorver: 4
minorver: 5
browser: Netscape
@@ -87,16 +86,22 @@ Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)
In order for this to work, your browscap configuration file - setting must point to the correct location of the - browscap.ini file. - - - For more information (including locations from which you may - obtain a browscap.ini file), check the PHP - FAQ at &url.php.faq;. + linkend="ini.browscap">browscap configuration setting in + &php.ini; must point to the correct location of the + browscap.ini file on your system. An up-to-date + browscap.ini file can be located + here. By default, this + browscap directive is commented out. + + + The cookies 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 setcookie, + reload, and check for the value. + +