php determines the type of server operating system
- 2021-01-02 21:47:35
- OfStack
1: php has many system predefined variables, which can easily determine whether the server system is windows or *unix, among which the related functions or predefined variables are as follows:
php_uname(), PHP_OS, DIRECTORY_SEPARATOR, PHP_SHLIB_SUFFIX, PATH_SEPARATOR
2: Examples:
<?php
if(strtolower(substr(PHP_OS, 0, 3)) == 'win'){
echo 'windows';
}else{
echo 'linux';
}