For building a unix/dos specific script I need to know on which kind of operating system I am.
How do i get this information?
phpinfo();
tells me a lot more and not very clear whether I'm running on unix or not.
For building a unix/dos specific script I need to know on which kind of operating system I am.
How do i get this information?
phpinfo();
tells me a lot more and not very clear whether I'm running on unix or not.
PHP has many predefined constants that are often useful.
Here,
PHP_OS
is the one you are looking for.For instance, on my current machine, this code :
Gives :
You have some examples and comparisons with what the
php_uname
function can get you on the manual page ofphp_uname
; for instance (quoting) :That page also says :
Just bear in mind that
PHP_OS
actually contains the platform on which PHP was built. This may not be the same platform as that on which it is deployed. Thereforephp_uname('s')
is more reliable.On php 7.2.0 you can use the
PHP_OS_FAMILY
constant:In other PHP version you can use: