PHP interaction with other languages-Summary-php Tutorial

Source: Internet
Author: User
PHP interaction with other languages-summary the original website will be updated constantly: Tsung's technical blog "PHP interaction with other languages-summary" it.zuocheng.net

Different modules of software or system may be written in different languages, and there will inevitably be problems of interaction and communication between different languages. From the perspective of PHP, This article explores how PHP interacts with other languages.

Language layer interaction using glue language

Glue language Shell scripts Python Ruby Lua Tcl Perl.

In essence, it is to call the input and output of an operating system. the operating system creates a new process for an application written in other languages and then returns the output to PHP.

It is easy to implement.

Disadvantages:

  • System calls are at risk;
  • Each call to the system creates a new process with high overhead
  • Complex data structures cannot be passed directly
  • Compile PHP extension

    Encapsulate the APIs provided by other languages into C interfaces (often compiled as dynamic link libraries) and encapsulate them in PHP extensions so that they can be directly called in PHP statements.

    Advantages:

  • High performance
  • It can realize interaction between complex structure data.
  • Disadvantages:

  • High development and O & M costs
  • Use PHP Native Interface (PNI)

    PNI is a PHP extension that allows PHP code to directly call C class libraries.

    Use SWIG

    The ultimate goal is to compile PHP Extensions. The difference is that the interfaces provided by SWIG allow developers to save learning costs compared with Zend APIs and PHP APIs.

    Inter-process interaction

    If you cannot directly interact with each other at the language level, you can use the interaction method between processes. The essence is to call the methods provided by the operating system for inter-process interaction.

  • Signal
  • Semaphores
  • MPs queue
  • Message Queue
  • Shared memory
  • Files, memory databases, etc.
  • Inter-system interaction

    If systems written in different languages interact with each other, you can use the following methods:

  • Network call (Http, Socket, Web Service)
  • Database
  • Data files
  • Distributed Systems (Memcache, Radis, rabitMQ)
  • 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.