Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is PHP thread-safe?

People also ask

Should PHP download thread-safe?

If you choose to run PHP as a CGI binary, then you won't need thread safety, because the binary is invoked at each request. For multithreaded webservers, such as IIS5 and IIS6, you should use the threaded version of PHP.

Is xampp PHP thread-safe or not?

XAMPP uses the Apache Software Foundation builds, and 'that' Apache build is Thread Safe.

Can we use multithreading in PHP?

PHP applications, undoubtedly work effectively with multithreading capabilities. Multithreading is something similar to multitasking, but it enables to process multiple jobs at one time, rather than on multiple processes.


I know gettext and set_locale is not threadsafe. PHP should not be used with a threaded MPM.

PHP Isn't Thread-Safe Yet.
Running PHP not threaded.


See Where can I get libraries needed to compile some of the optional PHP extensions? for a list of thread-safe and nonthread-safe extensions (* marked are not thread-safe and others are).


A better question might be, "Is the following PHP code going to trigger access violations if MPM is used?" Or, "Have you experienced odd behavior likely attributed to concurrency issues using the following functions?"

Otherwise, it's Russian roulette. If you're using some packaged application, it may work just fine now but break a month from now when a new version of the application comes out.

I strongly advise against using MPM with PHP in general. However, if you have some small code to run, you could post it, and we could tell you if you're going to hit a pitfall.