can i get browser info?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

can i get browser info?

Post by itsmani1 »

hi there...

is there any thing is php that can tell browser infomation? like if i want to know that browser has java script support or browser is java script enabled?

Regards!
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Max you can get directly is $_SERVER['HTTP_USER_AGENT']
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

get_browser : http://in.php.net/manual/en/function.get-browser.php

I tried this on my host :
Warning: get_browser(): browscap ini directive not set. in /xxx/xxx/getbrowser.php on line 2
Anyway to set it for ourself like the way we do in .htaccess ?
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

You need to get browscap.ini from a site like this http://www.garykeith.com/browsers/downloads.asp and set browscap in your php.ini before you can use it.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

But we cannot change php.ini on our host.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ask your host to add it, or make your own version of the function (it isn't hard)
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

i want to check if browser supports java script and if it does is java script is enabled on it??????
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

feyd wrote:ask your host to add it, or make your own version of the function (it isn't hard)
what do u mean how can one make his/her own ?
and you make ur own how will u use tht.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Isn't this why most people use <noscript> tags.... it seems the obvious way to output an alternative if JS is disabled, otherwise the JS will just execute if it is enabled... is there a reason you need to do the checking on the server? :?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

PHP will not be able to detect is JS is enabled; only if the browser has support for it. As d11wtq mentioned, <noscript> is intended for that. You can roll your own version by understanding how the get_browser() function works, which is simple pattern matching. You'll need to use parse_ini_file() to load the ini.. then flip through it searching for the browser.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

what i want to do is :
i want to run timer for 30 minutes on clint side of my page using java script because its very simple using java script.

is there any possibility to do so using php. if there is some thing plz. tell me.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

feyd wrote:PHP will not be able to detect is JS is enabled; only if the browser has support for it. As d11wtq mentioned, <noscript> is intended for that. You can roll your own version by understanding how the get_browser() function works, which is simple pattern matching. You'll need to use parse_ini_file() to load the ini.. then flip through it searching for the browser.
i just want u to tell me how can i know about browser behaviour, that either it supports java script or not and if it does is that enabled or not? if you can tell me pzl. tel
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

research the use of <noscript> :roll:
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

oki
Post Reply