143 PHP Interface

Source: Internet
Author: User
PHP Write App interface

PHP interface

    • Special abstract Classes
    • interface/implements keywords
    • All abstract methods that implement interface interfaces must be implemented

App interface

Defined

    • has an interface address that allows the client to send a request (Http://xxx/api.php?format=xml)
    • Have interface file (api.php), Get interface logic
    • Interface data,

App Communications

Client--(HTTP request to interface address), Serivice

Different from the B/S architecture

    • The address is encapsulated in the app (different from the browser address)
    • The client returns XML or JSON data (different from HTML)

XML (Extensible Markup Language) and JSON (JavaScript object notation)

Cross-platform, language.

    • Readability--XML
    • Easy-to-generate JSON

      Json_encode vs 4 ways to create XML

      • New DomDocument ()
      • Stitching strings
      • Xmlwrite
      • SimpleXml
    • Efficiency--JSON

Encapsulating data Interface Methods

Json

Json_encode only accepts Utf-8
transcoding iconv ("UTF-8", "GBK", $data)

Xml

Header ("Content-type:text/xml");

DomDocument
* createelement
* AppendChild

Standard format for communication data

    • Status codes (200 400)
    • Prompt message (login successful)
    • Data

Core technology

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the 143 PHP interface, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.