Results 1 to 3 of 3

Thread: How to encode or decode variables in PHP

  1. #1
    Join Date
    Jun 2009
    Posts
    1,518

    How to encode or decode variables in PHP

    I want to encode a variable in PHP5, do some operation and then decode it. For this I want to know which function is appropriate for this kind of operations. In short, is there any function that will encode and decode a variable? How any one provide me any solution with some details?

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to encode or decode variables in PHP

    You can use MySQL's encode and decode functions in your PHP code as follows:

    PHP Code:
    <?php
    $encVariable 
    mysql_query("SELECT ENCODE('variable_name','')");
    $encString mysql_fetch_array($encVariable);
    $val_enc $encodedString[0];
    echo 
    $val_enc."<br>\n";

    $decVariable mysql_query("SELECT DECODE('".$val_enc."','')");
    $decString mysql_fetch_array($decVariable);
    $val_dec $decString[0];
    echo 
    $val_dec;

    ?>

  3. #3
    Join Date
    Nov 2008
    Posts
    996

    Re: How to encode or decode variables in PHP

    Use urlencode () and urldecode (). Here is how to use them.

    urlencode

    This function is convenient when encoding a string to be used in a query part of a URL.

    PHP Code:
    string urlencode (string $str
    where,

    str = The string to be encoded.

    urldecode

    Decodes any encoding in the given string.

    PHP Code:
    string urldecode (string $str
    where,

    str = The string to be decoded.

Similar Threads

  1. How to encode URL in JavaScript and decode in PHP?
    By Linoo in forum Software Development
    Replies: 4
    Last Post: 25-02-2010, 10:24 PM
  2. How to encode and decode SMS text message
    By Ransom in forum Software Development
    Replies: 4
    Last Post: 11-02-2010, 01:08 AM
  3. How to encode dvd to mp4
    By Manthan in forum Windows Software
    Replies: 3
    Last Post: 21-08-2009, 12:45 PM
  4. MS excel url encode
    By Yancy in forum Windows Software
    Replies: 3
    Last Post: 17-07-2009, 07:17 PM
  5. PC crashes when I encode DVD
    By Blazej in forum Hardware Peripherals
    Replies: 4
    Last Post: 24-04-2009, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,821,051.40880 seconds with 16 queries