Dynadot โ€” .com Transfer

Convert PHP to ASP

SpaceshipSpaceship
Watch

billinchina

General BillEstablished Member
Impact
20
How would you convert this function to asp:

PHP:
function hello_world()
{
   $text1 = 'hello world';
   $text2 = 'goodbye world';

   global $HTTP_GET_VARS;

   $param2 = $stuff = '';

   if (isset($HTTP_GET_VARS['yea']))
   {
      if (substr($HTTP_GET_VARS['yea'], 0, 3) === 'yea')
         return serialize(array($text1, $text2));
   }
   $param1 = urlencode($text1);

   $handle = fopen("$param1$param2", 'r');
   while (!feof($handle))
      $stuff .= fgets($handle);
   fclose($handle);

   return $stuff;
}
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Hi, Bill... no time to debug or test it, but this should be the right general direction...
Code:
Function helloWorld()

   dim text1,text2,param,stuff
   dim handle

   text1 = "hello world"
   text2 = "goodbye world"

   MySer = Server.CreateObject("WDDX.Serializer.1")
   handle = Server.CreateObject("Msxml2.ServerXMLHTTP")

   If (Request.QueryString("yea")) Then
      If (Mid(Request.QueryString("yea"), 0, 3) === "yea") Then
         helloWorld = MySer.Serialize(array(text1,text2)); 
      End If
   End If 
   param1 = Server.URLEncode(text1)

   handle.open "GET", param1 & param2, False
   handle.send
   stuff = handle.responseText
   handle = Nothing

   helloWorld = stuff

End Function
I might look at that the handling of that array in a bit more of a formal way though (setting it to a variable before assigning that variable to something else). Not sure if ASP will like that "on the fly" stuff.

~ Nexus
 
Last edited:
0
•••
Thanks, I'm going to check this out later... I really appreciate your help.
 
0
•••
Is ASP just like VB?
 
0
•••
Kodeking said:
Is ASP just like VB?
Yes..It is similar to VBScript
 
0
•••
Kodeking said:
Is ASP just like VB?
Not just "similar". VBscript is a universal language Microsoft has wound through many of its products. While depending on the environment you many have more or less options, the language syntax is often the same. Similarly, you can configure ASP to use Javascript or Perl as its language. The only caveat is that its all or nothing. A "Javascript" page cannot include a VBScript page. Once you choose your language, you're off.

Bill, if you weren't bound by the above (your code is nastled in a bunch of other VB code), I'd use Javascript for your language interpreter. PHP is much easier to port to Javascript than VBscript. You get to keep your "{" and "}" structures, and your ";" at the end of your lines.

~ Nexus
 
0
•••
If I serialize an asp array with this:

helloWorld = MySer.Serialize(array(text1,text2));

Can I unsearialize it with php unserialize?
 
0
•••
Not really... put you'd be able to convert it. The MS serialization method "serializes" to XML. If you have a particular XML to array function you use in PHP, then that would solve it. I have one I use I could pass to you. You'd just need to compare the array you're expecting with the array you get (from doing this), and adjust it however necessary.

~ Nexus
 
0
•••
basicly i thought they were the same? but now i saw ASP is a lot lot harder dont ya think? gimme your comments.
 
0
•••
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Payment Flexibility
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back