Wednesday, 27 July 2016

Webservice



What is a web service?

In simple word web services is a collection of standards or protocols for exchanging information between two devices or applications. Web service is language independent way of communication. We just look bellow figure to more clear our concept.
web services
In above figure you can see java can communicate to other languages like .net, PHP and vice versa by using web services i.e. web services has no language limitation.
Types of Web Services
There are mainly two types of web services.
  1. SOAP web services.
  2. RESTful web services.
SOAP Web Services :-
SOAP stands for Simple Object Access Protocol. It is a XML-based protocol for accessing web services.
SOAP is a W3C recommendation for communication between two applications.
It is platform independent and language independent. By using SOAP, you will be able to interact with other programming language applications.
Advantages of Soap Web Services
WS Security: SOAP defines its own security known as WS Security.
Language and Platform independent: SOAP web services can be written in any programming language and executed in any platform.


Disadvantages of Soap Web Services
Slow: SOAP uses XML format that must be parsed to be read. It defines many standards that must be followed while developing the SOAP applications. So it is slow and consumes more bandwidth and resource.
WSDL dependent: SOAP uses WSDL and doesn't have any other mechanism to discover the service.
Web Service Components
  1. SOAP
  2. WSDL
  3. UDDI
SOAP: SOAP is an acronym for Simple Object Access Protocol.
WSDL: WSDL is an acronym for Web Services Description Language. WSDL is pronounced as wiz-dull.
WSDL is a xml document containing information about web services such as method name, method parameter and how to access it.
WSDL is a part of UDDI. It acts as a interface between web service applications.
UDDI: UDDI is an acronym for Universal Description, Discovery and Integration.
UDDI is a XML based framework for describing, discovering and integrating web services.
UDDI is a directory of web service interfaces described by WSDL, containing information about web services.

RESTful Web Services :-
REST stands for REpresentational State Transfer.
REST is an architectural style not a protocol.
Advantages of RESTful Web Services
Fast: RESTful Web Services are fast because there is no strict specification like SOAP. It consumes less bandwidth and resource.
Language and Platform independent: RESTful web services can be written in any programming language and executed in any platform.
Can use SOAP: RESTful web services can use SOAP web services as the implementation.
Permits different data format: RESTful web service permits different data format such as Plain Text, HTML, XML and JSON

Monday, 15 February 2016

Simple PHP mail Function

PHP mail Function

$to      = $email_id;
$subject = "";
$message = "Your mail Body Content. you also use here HTML Tags for better performence. ";
$headers = 'From: xyz@domainname.com' . "\r\n" .
    'Reply-To: xyz@domainname.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
$headers.= "MIME-Version: 1.0" . "\r\n";
$headers.= "Content-type:text/html;charset=UTF-8" . "\r\n";

$test=mail($to, $subject, $message, $headers);

Monday, 11 January 2016

PHP Magic Methods

PHP Magic Methods


1.      __construct()  :- This method is called when someone create the object of class. Constructor is use to load default variable or methods which is call default when page is load. Constructor also inherit like any other methods.
2.      __destruct()  :-  This magic method is called when object of your class is unset. It gets run when the object is destroyed, either expressly by us or when we're not using it any more and PHP cleans it up for us. The destructor lets us close up any external resources that were being used by the object.
3.       __get()  :-  it makes properties which actually don't exist appear as if they do. This method called when your object attempt to read property or variable of the class which is inaccessible or unavailable.
4.     __set()   :- This method called when object of your class attempts to set value of the property which is really inaccessible or unavailable in your class.
5.     __isset()   :- This magic methods trigger when isset() function is applied on any property of the class which is in accessible or unavailable.
6.       __unset()  :-  __unset is something opposite of isset method. This method triggers when unset() function called on inaccessible or unavailable property of the class.
7.       __sleep()   :-  this methods trigger when you are going to serialize your class object. When the object is serialised and then unserialised then these types of references are useless since the target may no longer be present or valid.
8.       __wakeup()  :- this is exactly opposite of sleep method and allows you to alter the behaviour of the unserialisation of the object.  
9.       __tostring()   :-  This method executes when you are using echo on your object. Definitely saving the best until last, the __toString method is a very handy addition to our toolkit.