Page 1 of 1

Simple asp.net to php conversion

Posted: Fri Jun 24, 2011 10:44 am
by lucaluca
Hi all,

I'm new to php, I nned to do a simple conversion from asp.net into php.

Who knows how to convert this:
_____________________________________________________________________________________________________
Dim url As String = "http://www.mywebsite.com"
Dim wc As WebClient = New WebClient()
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded")

' parameters - begin
Dim myQueryStringCollection As New System.Collections.Specialized.NameValueCollection()
myQueryStringCollection.Add("paramenter", paramenter)
wc.QueryString = myQueryStringCollection
' parameters - end

Dim myDatabuffer As Byte() = wc.DownloadData(url)

' Display the downloaded data.
Dim result As String = Encoding.ASCII.GetString(myDatabuffer)

wc.Dispose()

Response.Write(result)
_______________________________________________________________________________________

into php?

Many thanks.

Re: Simple asp.net to php conversion

Posted: Fri Jun 24, 2011 12:37 pm
by Christopher
Just a guess because I am not sure what a number of those methods do:

Code: Select all

           $url = "http://www.mywebsite.com";
           $result = file_get_contents($url);       // may not work in some configurations, so may need cURL or Snoopy
           // you may want to filter the data here with htmlenitities(), etc. for security
           header("Content-Type", "application/x-www-form-urlencoded");
           echo $result;