Web Hosting Talk







View Full Version : ASP - converting over some simple PHP functions


the_pm
04-15-2007, 11:57 AM
Hello everyone,

I have what I hope is a pretty basic question regarding ASP and converting over some simple PHP operations.

I'm looking for a way to identify components within a URL and take actions as a result of what's found. For example:

<?php
if (strpos($HTTP_HOST, 'example.com') !== FALSE) {
include('example.php');
}
?>

This snippet looks for the host name 'example.com' and upon finding it, includes the file 'example.php'. Real simple.

Another:<?php
if ($_SERVER['PHP_SELF'] === '/example.php') {
echo "
Foo!
";
}
?>This snippet looks for '/example.php' and finding it, echoes the string "Foo!"

How would these types of procedures be done in ASP? My familiarity with ASP is very low, but I can follow along with markup reasonably well :)

jimpoz
04-17-2007, 11:31 AM
The ASP function you need is InStr:

http://www.w3schools.com/vbscript/func_instr.asp


If Instr(Request.Servervariables("SCRIPT_NAME"), "/example.asp") > 0 Then Response.Write "Foo!"

the_pm
04-17-2007, 11:51 AM
Awesome. Thanks jimpoz :)