Home  >  Article  >  Backend Development  >  143 php interface

143 php interface

WBOY
WBOYOriginal
2016-07-29 09:01:111091browse

php Write app interface


php interface

  • Special abstract class
  • interface / implements keyword
  • implement interface All abstract methods of the interface must be implemented

app interface


definition

  • There is an interface address to allow the client to send a request (http://xxx/api.php?format=xml)
  • There is an interface file (api.php) to obtain the interface logic
  • interface data,

app communication

client -> (http request to interface address) -> serivice

The difference from b/s architecture

  • The address is encapsulated in the app (different from the browser address visible)
  • The client returns xml Or json data (different from html)

xml (extensible markup language) and json (JavaScript object notation)

cross platforms and languages.

  • Readability->
  • SimpleXml


  • Efficiency-> json

    • encapsulated data interface method
    • json
    • json_encode only accepts utf-8
    • Transcode iconv("UTF-8","GBK",$data)
    xml
  • header("Content-Type: text/xml");

DomDocument

* createElement

* appendChild

standard format of communication data

status code (200 400)

prompt information (login successful)

data


core technology

').addClass('pre-numbering'). hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i

').text(i)); }; $numbering.fadeIn(1700); }); });
  • The above introduces the 143 php interface, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn