PHP Path_separator determine the current server system type instance

Source: Internet
Author: User
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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.