How do I tell if the Browser supports PHP 5?

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

Locked
jcobban
Forum Commoner
Posts: 41
Joined: Mon Mar 08, 2010 7:40 am

How do I tell if the Browser supports PHP 5?

Post by jcobban »

I do not understand why there is apparently no agreed upon way to determine if the browser that you are generating code for is HTML5 compatible. I asked this in another forum and got back a comment that HTML5 is supposed to be backwards compatible, which is ridiculous. Even if I limit my HTML5 functionality to tags and attributes that are supported by HTML 4.1 the content of the page is still different and may be misunderstood by back-level browsers. And if I do limit my HTML to tags and attributes that are supported by HTML 4.1 what is the point? I might as well leave the page in HTML 4.1. But I cannot find anything anywhere on the web about how to tell from PHP whether it is safe to send HTML5 to the browser. The only useful comment I have received is that I can use the non-standard browser-side comment tags for identifying the browser support to enclose the HTML5-only code.

The "dive into HTML5" page tells me how Javascript can tell whether the browser it is running on supports various features of HTML5, but I have to get the web page to the browser before the Javascript can run.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: How do I tell if the Browser supports PHP 5?

Post by s.dot »

I have no idea about this topic..
But if javascript can detect it, why not detect it and do a javascript redirect to the appropriate version of the page.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How do I tell if the Browser supports PHP 5?

Post by requinix »

With PHP you'd have to resort to browser detection.

A lot of HTML 5 is backwards compatible. Most of the non-form additions have semantic meaning, not presentational. What HTML 5 stuff are you trying to use?
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: How do I tell if the Browser supports PHP 5?

Post by Eric! »

It seems that the javascript way of testing for HTML5 requires testing memory space for allowed HTML5 DOM options. You could use a AJAX style page that could test the browser, then pass the right parameters to a PHP page and render the appropriate HTML. However HTML5 should be compatible with older browsers because the HTML5 features of the object are ignored.

If you want to try it all in PHP, try the $_SERVER['HTTP_USER_AGENT'] and process agents you know to be HTML5 compatible or also try the get_browser function.... The browscap.ini file that it loads will slow down your page some.

Also there is phpSniff which doesn't quite meet your needs, it might be helpful in understanding the client. http://phpsniff.sourceforge.net/
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How do I tell if the Browser supports PHP 5?

Post by pickle »

This is essentially a duplicate of your other thread.

Locking.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Locked