Home  >  Article  >  Backend Development  >  What are the disadvantages of single threading in php?

What are the disadvantages of single threading in php?

青灯夜游
青灯夜游Original
2019-10-16 13:23:593403browse

PHP, "Hypertext Preprocessor", is a general open source scripting language. PHP is a scripting language executed on the server side. It is similar to C language and is a commonly used website programming language. PHP's unique syntax mixes C, Java, Perl, and PHP's own syntax. It is conducive to learning and widely used. It is mainly suitable for the field of web development.

What are the disadvantages of single threading in php?

PHP is single-threaded, so what are the disadvantages of PHP being single-threaded?

PHP has always been a single-process program; although PHP's pthreads extension has long been available. But it is not stable enough, and it will hang up inexplicably while running; PHP extensions are all written in C, which means that if any extension has thread competition resource control problems, the whole thing will hang up

Disadvantages of single-threaded PHP

1), function naming is not standardized, camel case method and underline, different parameter transfer positions you know

2), single-threaded ; PHP itself has always been a single-process program; although PHP's pthreads extension has long been available. But it is not stable enough, and it will hang up inexplicably while running; PHP extensions are all written in C, which means that if any extension has thread competition resource control problems, the whole thing will hang up

3), the core asynchronous network is not supported (of course, there is only a synchronous non-blocking network model in Linux). But the lack of this makes it difficult to develop a network application that can withstand large concurrency. Both traditional network models and io are blocking. The basic programming approach is that a process (or thread) responds to a user connection request. Therefore, it is impossible to complete tasks like real-time online games that require thousands of network connections. Although PHP also has Libevent and eio extensions, which can make up for this to some extent, they feel that they are not so perfect

4), only supports web development, and it is not convenient to make .exe files or desktop applications. . It is not convenient to make mobile phone programs.

5) It is not suitable for crawlers, automatic running scripts, and scientific computing projects. The basic structure of this language is not suitable, although there are many ways to achieve it.

6), later maintenance is difficult. The speed-up space in the later period is quite limited.

7), PHP’s interpretation and operation mechanism. This operating mechanism enables all related resources to be recycled after each PHP page is interpreted and executed. In other words, PHP has no way to make an object resident in memory at the language level.

In PHP, all variables are page-level. Whether they are global variables or static members of the class, they will be cleared after the page is executed. Take JSP as an example. In JSP, the scope of Java Bean has four valid values: Page, Application, Session, and Request, which correspond to the four lifetimes of page, program, session, and request respectively. But in PHP, there is only one lifetime of Page.

For more PHP related knowledge, please visit php中文网!

The above is the detailed content of What are the disadvantages of single threading in php?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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