This is a discussion on Using different stylesheets + generating HTML in PHP (how to)? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I have spent the last few days trying to create a tableless web page, using CSS only for layout. I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have spent the last few days trying to create a tableless web page,
using CSS only for layout. I have finally given up. My current css file works fine for IE - but looks terrible in Netsacpe and Firefox. if I fix the issue so that it works for Netscape/Firefox, then the page looks like crap in IE. I have finally decided to use two different style sheets (one is a minor modification of teh other),l and generate the HTML page dynamically =- and use a link to the appropriate stylesheet - depending on the UA (browser) making teh request for the page. The (simplified) logic is something like this : $user_agent = get_user_agent(); if ($user_agent == IEXPLORER) generate_Iexplorer_page(); else generate_mozilla_page(); I am new to PHP (I'm a C++ programmer), so I would appreciate it if someone could show me how to do the following: 1). Write a function to determine the UA (user agent - i.e. browser) type 2). generate html page with the appropriate css file link. For the purposes for the code snippet, you can assume that the (path) names of the css files are : .../mozilla.css (css for mozilla browsers) .../explorer.css (css for Iexplorer browsers) Also please assume that the HTML page to be genrated consists of teh ff simple HTML: <html> <head> <title>This is a test</title> <link rel="stylesheet" type="text/css" href="xxx.css" /> </head> <body>Some text goes here ...</body> </html> |
|
|||
|
> I am new to PHP (I'm a C++ programmer), so I would appreciate it if
> someone could show me how to do the following: > 1). Write a function to determine the UA (user agent - i.e. browser) type somethin like $cssfile = (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.css'; > 2). generate html page with the appropriate css file link. > <html> > <head> > <title>This is a test</title> <link rel="stylesheet" type="text/css" href="<?php echo $cssfile; ?>" /> > </head> > <body>Some text goes here ...</body> > </html> |
|
|||
|
Floortje wrote: > > I am new to PHP (I'm a C++ programmer), so I would appreciate it if > >> someone could show me how to do the following: > > > > >> 1). Write a function to determine the UA (user agent - i.e. browser) type > > > somethin like > $cssfile = (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.css'; > > >> 2). generate html page with the appropriate css file link. > > >> <html> >> <head> >> <title>This is a test</title> > > > <link rel="stylesheet" type="text/css" href="<?php echo $cssfile; ?>" /> > > >> </head> >> <body>Some text goes here ...</body> >> </html> Cool - thanks very much ! |
![]() |
| Thread Tools | |
| Display Modes | |
|
|