Tuesday 24 July 2012

What is JSON?

JSON is JavaScript Object Notation. It is a lightweight data-interchange format and language independent also. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript etc. These properties make JSON an ideal data-interchange language.


JSON data comes in two structures
  1. Name/Value pairs   
  2. An ordered list of values
These are universal data structures. Virtually all modern programming languages support them in one form or another.
JSON value can be string, number, null, array, object.
JSON data can one of these form(s).


Name/Value pair
JSON data is written as name/value pairs.
A name/value pair consists of a field name in double quotes, followed by a colon, followed by a value.
e.g. "age" : "28"


JSON Objects
JSON objects are written inside curly brackets,
Objects can contain multiple name/values pairs:
e.g. { "Name":"John" , "age":"28" } 


JSON Arrays
JSON arrays are written inside square brackets.
An array can contain multiple objects:
e.g. {
"employees": 
            [
{ "Name":"John" , "age":"28" },
{ "Name":"mick" , "age":"23" }
          ]
       }


The MIME type for JSON text is "application/json".

Monday 11 June 2012

What is codec?



A codec is a program, capable of encoding or decoding a digital data stream or signal. The word codec is a short form of "compressor - decompressor" or "coder - decoder", takes a raw data file and turns it into a compressed file.
A codec encodes a data stream or signal for transmission, storage or encryption, or decodes it for playback or editing.

Why we need codec?

video and audio files are large, so difficult to transfer across the Internet quickly. To help speed up downloads, mathematical "codecs" were built to encode ("shrink") a signal for transmission and then decode it for viewing or editing. Without codecs, downloads would take three to five times longer than they do now.

What are the common codecs people use?

Some codec examples are MP3, WMA, RealVideo, RealAudio, DivX and XviD. There are many other more obscure codecs.

what is Audio codec?

An audio codec converts analog audio signals into digital signals for transmission or storage. A receiving device then converts the digital signals back to analog using an audio decompressor, for playback. Example of this are the codecs used in the sound cards of personal computers.

what is Video codec?

An video codec converts analog video signals into digital signals for transmission or storage. A receiving device then converts the digital signals back to analog using video decompressor.

Means if there is a string with double quotes and if you place a variable in that, it will substitute its value in string.
This is the main difference.
Reference : http://www.scriptvenue.com/2011/10/difference-between-double-quotes-and-single-quotes-in-php/

What is a Payment Gateway?



A payment gateway is a technique to process transactions electronically. Payment gateways provide the tools to process payments between customers, businesses, and banks.A payment gateway is a necessary part of the transaction between customer, business and the banking institutions that both are using. A payment gateway is used to facilitate electronic transactions. These are very safe, as it uses Encryption of payment and personal data.

What is CURL ?




cURL
 means client URL, allows you to connect and communicate to many different types of servers with many different types of protocols.

It supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols.
To use CURL we use libcurl library. libcurl library is by default built-in in XAMPP. To check weather it is supports or not, check a phpinfo() program to see if you now have curl support listed. if it is not, then 
  • find php.ini file.
  • search for the line ;extension=php_curl.dll 
  • remove the semicolon from the beginning of the line.
  • save the file and restart apache.

check a phpinfo() again. it is supportable now.

libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT etc.

There are some function which we use, while using libcurl.

  • curl_init() : It Initialize a cURL session.
  • curl_setopt : It sets an option for a cURL transfer.e.g. (CURLOPT_URL, CURLOPT_POSTFIELDS, CURLOPT_RETURNTRANSFER etc. these are some predefined constants.)
  • curl_exec() : Run a cURL session.
curl_close() : Close a cURL session.

Difference between double quotes and single quotes in PHP



In PHP string data is enclosed in quotes either single or double quotes. But sometimes programmers get confused in difference between single quote and double quote.
Let me tell you what is main difference between single quotes and double quotes theoretically & also practically too.
Single quotes do not support variable expansion but double quotessupport.Means if there is a string with single quotes and if you place a variable in that, it won’t substitute its value in string.
e.g.
<?PHP
         $str = 'QAPHP';
         echo '$str is a Blog which provides Question & Answers.';
?>

Output will be:: $str is a site which provides Question & Answers.
In case of double quoted string…

<?PHP
         $str = 'QAPHP';
         echo "$str is a site which provides tips.";
?>

Output will be:: QAPHP is a Blog which provides Question & Answers.

Means if there is a string with double quotes and if you place a variable in that, it will substitute its value in string.
This is the main difference.
Reference : http://www.scriptvenue.com/2011/10/difference-between-double-quotes-and-single-quotes-in-php/