Results 1 to 2 of 2

Thread: CGI code to PHP code help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    111

    CGI code to PHP code help

    Hello everyone,

    I need a favor.

    I need to convert this CGI code to PHP code. I don't know about CGI or Perl so i couldn't convert it myself.

    Code:
    sub URL_encode {
        my($URL)= @_ ;
        $URL=~ s#^([\w+.-]+)://#$1/# ;		     # http://xxx -> http/xxx
        $URL=~ s/(.)/ sprintf('%02x',ord($1)) /ge ;   # each char -> 2-hex
        $URL=~ tr/a-zA-Z/n-za-mN-ZA-M/ ;		  # rot-13
        return $URL ;
    }
    I will really appreicate if someone could help me out.

    Thanks in advance

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: CGI code to PHP code help

    My knowledge of Perl is rather basic, so I'm not sure this is right, but maybe...
    Code:
    function URL_encode($url){
      $url = preg_replace("#^([\w+.-]+)://#","$1/",$url);
      $url = preg_replace("/(.)/e"," sprintf('%02x',ord('$1')) ",$url);
      $url = str_rot13($url);
      return $url;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width