什么是SAPI以及何时使用它?

时间:2021-03-20 14:35:11

I've been learning about error handling in PHP recently and came across the error_log() function.

我最近一直在学习PHP中的错误处理,并遇到了error_log()函数。

In the PHP manual, it talks about all the error log types and I understand all of them except for type 3 which states that the error message is sent directly to the SAPI logging handler. My question is what exactly is SAPI and when would you want to use it?

在PHP手册中,它讨论了所有错误日志类型,我理解所有这些类型除了类型3,其中指出错误消息直接发送到SAPI日志记录处理程序。我的问题是SAPI究竟是什么以及您何时想要使用它?

3 个解决方案

#1


36  

SAPI stands for "Server API". It is the mechanism that controls the interaction between the "outside world" and the PHP/Zend engine. So, you would always want to use it. In fact, you cannot avoid using it without a lot of effort since even CLI is considered a SAPI.

SAPI代表“服务器API”。它是控制“外部世界”和PHP / Zend引擎之间交互的机制。所以,你总是想要使用它。事实上,你不能不费力地使用它,因为即使CLI被认为是SAPI。

#2


16  

SAPI ( Server Application Programming Interface ) also know as ISAPI ( Internet Server Application Programming Interface) for Microsoft, NSAPI (Netscape Server Application Programming Interface) for Netscape.

SAPI(服务器应用程序编程接口)也称为用于Microsoft的ISAPI(Internet服务器应用程序编程接口),用于Netscape的NSAPI(Netscape服务器应用程序编程接口)。

API meaning.

API含义。

For web developer, you can think of API such as REST, SOAP. You call a link you get a data from server. It allows you interact with the web server.

对于Web开发人员,您可以考虑使用REST,SOAP等API。您调用从服务器获取数据的链接。它允许您与Web服务器进行交互。

SAPI is different with REST or SOAP, SAPI is API (contract) used for server.

SAPI与REST或SOAP不同,SAPI是用于服务器的API(契约)。

For example: Common Gateway Interface is an SAPI. If a web server support CGI and another executable program implement it so web server can inteface and generate web pages dynamically.

例如:通用网关接口是SAPI。如果Web服务器支持CGI和另一个可执行程序实现它,那么Web服务器可以交互并动态生成Web页面。

Look the picture below:

看下图:

什么是SAPI以及何时使用它?

mod_php implement an interface which apache and php can understand each other.

mod_php实现了一个apache和php可以互相理解的接口。

So what is SAPI exactly: It is a contract between Server (any kind of server) and the program. Just follow the contract and they don't need to know other side details.

那么什么是SAPI:它是Server(任何类型的服务器)和程序之间的契约。只需按照合同,他们不需要知道其他方面的细节。

#3


14  

From Wikipedia:

来自*:

In other words, SAPI is actually an application programming interface (API) provided by the web server to help other developers in extending the web server capabilities.

换句话说,SAPI实际上是Web服务器提供的应用程序编程接口(API),以帮助其他开发人员扩展Web服务器功能。

As an example, PHP has a direct module interface called SAPI for different web servers; in case of PHP 5 and Apache 2.0 on Windows, it is provided in form of a DLL file called php5apache2.dll, which is a module that, among other functions, provides an interface between PHP and the web server, implemented in a form that the server understands. This form is what is known as a SAPI.

例如,PHP有一个名为SAPI的直接模块接口,用于不同的Web服务器;在Windows 5上的PHP 5和Apache 2.0的情况下,它以一个名为php5apache2.dll的DLL文件的形式提供,该文件是一个模块,除其他功能外,还提供PHP和Web服务器之间的接口,以一种形式实现服务器理解。这种形式就是所谓的SAPI。

There are different kinds of SAPIs for various web server extensions. For example, another two SAPIs for the PHP language are Common Gateway Interface (CGI) and command-line interface (CLI).

各种Web服务器扩展有不同种类的SAPI。例如,PHP语言的另外两个SAPI是通用网关接口(CGI)和命令行接口(CLI)。

#1


36  

SAPI stands for "Server API". It is the mechanism that controls the interaction between the "outside world" and the PHP/Zend engine. So, you would always want to use it. In fact, you cannot avoid using it without a lot of effort since even CLI is considered a SAPI.

SAPI代表“服务器API”。它是控制“外部世界”和PHP / Zend引擎之间交互的机制。所以,你总是想要使用它。事实上,你不能不费力地使用它,因为即使CLI被认为是SAPI。

#2


16  

SAPI ( Server Application Programming Interface ) also know as ISAPI ( Internet Server Application Programming Interface) for Microsoft, NSAPI (Netscape Server Application Programming Interface) for Netscape.

SAPI(服务器应用程序编程接口)也称为用于Microsoft的ISAPI(Internet服务器应用程序编程接口),用于Netscape的NSAPI(Netscape服务器应用程序编程接口)。

API meaning.

API含义。

For web developer, you can think of API such as REST, SOAP. You call a link you get a data from server. It allows you interact with the web server.

对于Web开发人员,您可以考虑使用REST,SOAP等API。您调用从服务器获取数据的链接。它允许您与Web服务器进行交互。

SAPI is different with REST or SOAP, SAPI is API (contract) used for server.

SAPI与REST或SOAP不同,SAPI是用于服务器的API(契约)。

For example: Common Gateway Interface is an SAPI. If a web server support CGI and another executable program implement it so web server can inteface and generate web pages dynamically.

例如:通用网关接口是SAPI。如果Web服务器支持CGI和另一个可执行程序实现它,那么Web服务器可以交互并动态生成Web页面。

Look the picture below:

看下图:

什么是SAPI以及何时使用它?

mod_php implement an interface which apache and php can understand each other.

mod_php实现了一个apache和php可以互相理解的接口。

So what is SAPI exactly: It is a contract between Server (any kind of server) and the program. Just follow the contract and they don't need to know other side details.

那么什么是SAPI:它是Server(任何类型的服务器)和程序之间的契约。只需按照合同,他们不需要知道其他方面的细节。

#3


14  

From Wikipedia:

来自*:

In other words, SAPI is actually an application programming interface (API) provided by the web server to help other developers in extending the web server capabilities.

换句话说,SAPI实际上是Web服务器提供的应用程序编程接口(API),以帮助其他开发人员扩展Web服务器功能。

As an example, PHP has a direct module interface called SAPI for different web servers; in case of PHP 5 and Apache 2.0 on Windows, it is provided in form of a DLL file called php5apache2.dll, which is a module that, among other functions, provides an interface between PHP and the web server, implemented in a form that the server understands. This form is what is known as a SAPI.

例如,PHP有一个名为SAPI的直接模块接口,用于不同的Web服务器;在Windows 5上的PHP 5和Apache 2.0的情况下,它以一个名为php5apache2.dll的DLL文件的形式提供,该文件是一个模块,除其他功能外,还提供PHP和Web服务器之间的接口,以一种形式实现服务器理解。这种形式就是所谓的SAPI。

There are different kinds of SAPIs for various web server extensions. For example, another two SAPIs for the PHP language are Common Gateway Interface (CGI) and command-line interface (CLI).

各种Web服务器扩展有不同种类的SAPI。例如,PHP语言的另外两个SAPI是通用网关接口(CGI)和命令行接口(CLI)。