Find if the installed PHP is threadsafe or nonthreadsafe?
How do I find out whether the installed version of PHP is threadsafe or not thread safe?
Please note that I'm not asking the difference between a threadsafe/non thread safe installation. I would like to find out what is installed currently.
Open a phpinfo() and search for the line Thread safety. For a thread-safe build you should find enable.
As specified in the comments by Muhammad Gelbana you can also use:
- On Windows :
php -i|findstr "Thread"
- On *nix:
php -i|grep Thread
If you prefer to use the command line:
-
*nix:
php -i | grep -i "Thread"
-
Windows:
php -i | findstr -i "thread"
This should give you something like this:
Thread Safety => enabled
or
Thread Safety => disabled
I just find it easier to look at the file named php[version].dll in the root folder of php. Its either php[version].dll or php[version]ts.dll (ts standing for Thread Safe). So, if you have php7.0.10 installed, go to the directory that has this name and you'll find a file named php7ts.dll. This is a very sad way of finding out, but it works!
Then there's the undocumented ZEND_THREAD_SAFE
constant, which seems to exist since PHP 4.3.
<?php
if (ZEND_THREAD_SAFE) {
echo 'Thread safe';
} else {
echo 'Not thread safe';
}
https://3v4l.org/tALKX