How to check if your code environment is running on Windows or Linux or another OS

Right now, I am ordering a custom Wordpress theme and testing it in xampp windows XP on an apache server. But while I'm worried, there is no built-in wp function to identify the code environment. Is there a built-in PHP function to identify such a thing?

for the record, what I want to encode must be read in the directory. in my apache (in windows) the path will be c: / xampp / htdocs, where apache on linux will be \ somepath \ somepath \

So, is there any solution for the code to find out what the OS is without having to extract and compare the path? I hope that it will also work with other OSs with a different web server, then APACHE, for example IIS

+3
source share
2 answers

You want php_uname()for this and maybe php_sapi_name().

+5
source

$_SERVER['SERVER_SOFTWARE']should do it for you. Use strposWin32 or Unix to search.

+1
source

Source: https://habr.com/ru/post/1737636/


All Articles