cvs: /phpdoc/chapters config.sgml /phpdoc/functions misc.sgml

From: Date: Tue, 21 Sep 1999 21:45:16 +0000
Subject: cvs: /phpdoc/chapters config.sgml /phpdoc/functions misc.sgml
Groups: php.dev 
Request: Send a blank email to php-dev+get-11169@lists.php.net to get a copy of this message
cslawi Tue Sep 21 17:45:16 1999 EDT Modified files: /phpdoc/chapters config.sgml /phpdoc/functions misc.sgml Log: Documented get_browser(). Index: phpdoc/chapters/config.sgml diff -u phpdoc/chapters/config.sgml:1.6 phpdoc/chapters/config.sgml:1.7 --- phpdoc/chapters/config.sgml:1.6 Tue Sep 21 04:50:57 1999 +++ phpdoc/chapters/config.sgml Tue Sep 21 17:45:16 1999 @@ -1247,7 +1247,8 @@ </term> <listitem> <para> - Name of browser capabilities file. + Name of browser capabilities file. See also + <function>get_browser</function>. </para> </listitem> </varlistentry> Index: phpdoc/functions/misc.sgml diff -u phpdoc/functions/misc.sgml:1.7 phpdoc/functions/misc.sgml:1.8 --- phpdoc/functions/misc.sgml:1.7 Tue Sep 21 06:37:22 1999 +++ phpdoc/functions/misc.sgml Tue Sep 21 17:45:16 1999 @@ -286,6 +286,119 @@ </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>

« previous php.dev (#11169) next »