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.