Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 26-08-2009
Member
 
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?
Reply With Quote
  #2  
Old 26-08-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
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;

?>
Reply With Quote
  #3  
Old 26-08-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to encode or decode variables in PHP"
Thread Thread Starter Forum Replies Last Post
How to encode URL in JavaScript and decode in PHP? Linoo Software Development 4 25-02-2010 10:24 PM
How to encode and decode SMS text message Ransom Software Development 4 11-02-2010 01:08 AM
How to encode dvd to mp4 Manthan Windows Software 3 21-08-2009 12:45 PM
MS excel url encode Yancy Windows Software 3 17-07-2009 07:17 PM
PC crashes when I encode DVD Blazej Hardware Peripherals 4 24-04-2009 09:05 PM


All times are GMT +5.5. The time now is 03:19 PM.