Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp vs php

Status
Not open for further replies.

gyzmoe

Programmer
Sep 27, 2001
1
US
I don't know PHP, though I am about to delve into it so I don't have to ask stupid questions.

I need to convert this asp into PHP, if someone can let me know the syntax so I can complete this project, I promise promise I will find a tutorial and learn it myself this weekend!

here is the asp:
response.redirect("
url = request.querystring("url")

response.write(URL)

PLEASE help me!!
 
in php all strings have a dollar sign in front of them (and its all automatic!)
so if the URL is passed forward in the querystring (something.php?url=then $url is already
Easy huh?

Then to write it to the screen use echo

<?php
echo &quot;$url is a cool site&quot;
?>


is a great starting place!
 
OK, I think what gyzmoe is really asking for is a way of sending a Location header, to redirect the browser to another URL.

And bevan, I hate to be a perfectionist, but in PHP you don't say &quot;All strings have a dollar sign&quot;. It is better to say &quot;All variable names start with a dollar sign&quot;. A string can consist of any characters you want. I'm sure you know this, but I wanted to make sure that gyzmoe is not confused.

Anyway, the code translated to PHP would be:
Code:
header(&quot;Location: [URL unfurl="true"]http://www.website.com?url=www.website.com&quot;);[/URL]

print ($url);

Normally, with PHP, any key/value pair in the querystring is automatically available as a variable (with the dollar sign). If PHP is set up in &quot;strict mode&quot;, then you would need to define you variable from the global HTTP vars array:
Code:
$url = HTTP_GET_VARS[&quot;url&quot;];
print($url);

Also, the &quot;echo&quot; statement is the same thing as &quot;print()&quot;, essentially, so you could express it as:

Code:
echo $url;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top