Forum Moderators: open

Message Too Old, No Replies

PHP to ASP conversion

It works in PHP, would like to provide this code in ASP too though...

         

JAB Creations

7:20 pm on Aug 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could someone be so kind as to convert this PHP to ASP for me please? - John

<?php

$useragent = $_SERVER['HTTP_USER_AGENT'];

if (preg_match("/MSIE 5.5/i", "$useragent")) {echo ' <!--[if
IE]><link href="http://www.example.com/themes/ieccss5.5.css"
media="screen" rel="stylesheet" title="ieccss5.5"
type="text/css" /><![endif]-->
';}

else if (preg_match("/MSIE 5/i", "$useragent")) {echo ' <!--[if
IE]><link href="http://www.example.com/themes/ieccss5.css"
media="screen" rel="stylesheet" title="ieccss5"
type="text/css" /><![endif]-->
';}

else if (preg_match("/MSIE 6/i", "$useragent")) {echo ' <!--[if
IE]><link href="http://www.example.com/themes/ieccss6.css"
media="screen" rel="stylesheet" title="ieccss6"
type="text/css" /><![endif]-->
';}

else if (preg_match("/MSIE 7/i", "$useragent")) {echo ' <!--[if
IE]><link href="http://www.example.com/themes/ieccss7.css"
media="screen" rel="stylesheet" title="ieccss7"
type="text/css" /><![endif]-->
';}
?>

wardbekker

10:12 am on Aug 28, 2006 (gmt 0)

10+ Year Member



Hi Jab,

(Anything else? Taking out the trash or something?)

Sorry, do you have trouble with converting a specific PHP statment to ASP in this code?

percentages

10:33 am on Aug 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's about 40 characters to convert.......not that tough!

I would suggest learning ASP!

I would do it for you, but, as a retired person that always believed I should die before fail to solve a challenge I don't feel that inclined ;)

topr8

11:46 am on Aug 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



IF (instr($useragent,"/MSIE 5.5/i" )>=1) THEN
response.write(" <!--[if IE]><link href=""http://www.example.com/themesieccss5.5.css"" media=""screen"" rel=""stylesheet"" title=""ieccss5.5"" type=""text/css"" /><![endif]--> ")

ELSEIF ...

JAB Creations

9:35 pm on Aug 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know ASP however I would like to provide a working example of this code in ASP for those who use it.

It's about 40 characters to convert.......not that tough!

Everything is easy once you know...but I don't know!

Thanks topr8...

- John

mattglet

1:45 am on Aug 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JAB-

You won't be needing the $useragent variable... that's PHP.

Replace your $useragent declaration with this:

UserAgent = Request.ServerVariables("HTTP_USER_AGENT")

Then you can do:
IF (instr(UserAgent,"/MSIE 5.5/i" )>=1) THEN

That should do the trick.

Easy_Coder

2:25 am on Aug 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Keep posting here Jab... we're not all going to tell you to 'stuff if' and go learn on your own.