Skip to main content

Posts

Showing posts from 2014

Hack : A Look at Programming Language By Facebook

As every PHP developer should be aware of the Programming Language developed by Facebook : Hack. It is basically based on PHP, you can say PHP but a strongly / statically typed language like Java .(i.e. a language which have fixed datatype). Let me give you a simple example. In normal PHP ,we have functions like <?php function addOne($num1){      return ($num1+1) ; } ?> But in hack this code will be changed to <?hh  function addOne(int $num1) : int{      return ($num1+1); }  You must have notice the major difference. Inside function parameters, in HACK, we have mentioned int as datatype and int as return type. This is one of major difference between PHP and Hack. But this is not the only reason, Why Hack actually evolves?? Basically, We have an advantage in PHP that it need not to be compiled(unlike java), just make changes in file and reload the browser. Languages like Java are slow in sense that they first need to be compiled, then they can be run, but

JSON : Tutorial and Usage

Json Introduction What is JSON? JSON stands for J ava S cript O bject N otation JSON is lightweight text-data interchange format JSON is language independent * JSON is "self-describing" and easy to understand JSON uses JavaScript syntax for describing data objects, but JSON is still language and platform independent. JSON parsers and JSON libraries exists for many different programming languages. Json Format Example : {     "employees": [         {             "firstName": "John",             "lastName": "Doe"         },         {             "firstName": "Anna",             "lastName": "Smith"         }     ] } Why JSON? For AJAX applications, JSON is faster and easier than XML: Using XML Fetch an XML document Use the XML DOM to loop through the document Extract values and store in variables Using JSON

MongoDB with PHP – Configuration and Examples

So, in previous posts, we have seen What is MongoDB and how we can perform CRUD operation on MongoDB .  So, moving ahead, lets learn how to use MongoDB with PHP.  By default, PHP assumes you will be using MySQL, so till now it doesn’t support MongoDB. But we can add the Mongo DB support to our existing PHP. On Windows https://s3.amazonaws.com/drivers.mongodb.org/php/index.html Go to the link, download the suitable version of zip. This zip contains the dll for mongo you will be using. Just unzip the zip file, and select the appropriate version of the dll(for ex, if you are using php 5.3.13 and you have downloaded the php_mongo-1.4.5.zip   , on 32-bit systems, you needs to use the php_mongo-1.4.5-5.3-vc9.dll from the zip.   So select the appropriate version as per 32/ 64 bit and your PHP version. Then just rename the dll file to php_mongo.dll and paste it to your php extensions directory.( ext by default). Then open your php.ini file, add the line   ex