Simple asp.net to php conversion

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lucaluca
Forum Newbie
Posts: 1
Joined: Fri Jun 24, 2011 10:38 am

Simple asp.net to php conversion

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Simple asp.net to php conversion

Post 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;
(#10850)
Post Reply