This article mainly introduces PHP path_separator to determine the current server system type instance of the relevant information, the need for friends can refer to the following
PHP has a very useful pre-defined constant, path_separator, which we can use to determine whether the current server is Linux or Windows. This article will explain PHP using Path_separator to get the current server type.
Path_separator is a predefined constant in PHP, we can directly echo this constant, in a Linux system, the constant output ":" In the Windows system, the constant output ";" No. Therefore, we can determine the current server system type by path_separator the output value.
To output the results in a Linux system:
<?php var_dump (path_separator); Output: String (1) ":"?>
Output results in Windows system:
<?php var_dump (path_separator); Output: String (1) ";"? >
Write a function that determines the current server system type:
function Getos () {if (Path_separator = = ': ') {return ' Linux ';} else{return ' Windows ';}}
How to determine the current server system type, you can call the above function directly.
The above is the whole content of this article, I hope that everyone's study has helped.