Home > Backend Development > PHP Tutorial > Extension and embedding of PHP--General outline_PHP tutorial

Extension and embedding of PHP--General outline_PHP tutorial

WBOY
Release: 2016-07-13 17:18:40
Original
954 people have browsed it

I initially came into contact with PHP development and PHP extension related content, and found that the book Extending and Embeded PHP is very good, and many issues are also explained very thoroughly. Here I will combine the content of some books I have read with my own practice to show it. It is not only a record for myself, but also a way to attract new ideas. I look forward to the guidance of PHP experts.

There is also a Chinese version of the book extending and embeded php. Some things are new, you can also refer to it:
http://www.walu.cc/phpbook/preface.md

This book mainly talks about two aspects:

  • How to extend php by adding functions, classes, resources and streams

  • How to embed PHP language into other applications So why do you need a php extension? :
    • Connect additional libraries and provide them as an API to user space scripts . For example, encapsulated mysql
      • provides an extension between third-party libraries and the core of PHP, so PHP is called the glue language
      • performs special internal operations, such as declaring super variables . User space is restricted for security reasons. For example, php's advanced php debugger and runkit are mainly used for this
      • Speed ​​reasons: Tokenization, compilation, and running. Opcode can reduce the first two steps, but if this step is executed, it will still become C code Better.
      • Provide functionality without exposing source code
        The overall structure of php is given in the figure below:

        The functions of each module are as follows:
        SAPI: It is the interface layer with the web server PHP Core: For the connection layer of core events, it handles operations such as file processing and error handling. Zend Engine: Compile scripts into machine language, execute bytecode, read and write user space variables, control program flow, and parse expansion. TSRM: thread safe resource management: enables a single php instance to have the ability to handle many independent requests at the same time This book is divided into three parts. The first part is a reintroduction to PHP, which mainly describes how the PHP interpreter is glued together. The second part mainly talks about PHP extensions, and the aspects involved are as follows:
        • PHP API Some PHP internal functions and macros
        • How to convert PHP scripts into C code: Behind each PHP script involves corresponding processing of the C language. This correspondence is very useful for the development of extensions
        • Perform operations that are impossible in user space: Many times it is necessary to perform actions similar to super variables that cannot be completed in user space. At this time, extensions need to be used for corresponding processing. The third part describes how to embed PHP into the corresponding application:
          • The first is to add corresponding PHP support to the application
          • The second is to make full use of the corresponding security features of PHP
          • The last is to explain how PHP handles multiple requests at the same time Since I have just started learning PHP, some mistakes are inevitable. Please correct me.

            www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621630.htmlTechArticleI have initially come into contact with PHP development and PHP expansion related content, and found that the book extending and embeded PHP is very good, and there are many The questions are also explained very thoroughly. Here are the contents of some books I read...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template