How to use PHP to determine the type of server operating system _php tips

Source: Internet
Author: User
I am using the WinXP, but upload the server is Linux, each upload always need to change the configuration file, there are some other things,
Now, by judging the type of the current server to decide what kind of program to perform, how does PHP determine what type of server it is in?
PHP has many system predefined variables, by which they can simply judge whether the system is windows or *unix
The related functions or predefined variables are as follows
Copy Code code as follows:

Php_uname ();
Php_os
Directory_separator
Php_shlib_suffix
Path_separator

Specific procedures:
Copy Code code as follows:

?
if (path_separator== ': ') echo ' Linux ';
else echo ' Windows ';
?>

Or
Copy Code code as follows:

<?php
Echo php_uname ();
Echo Php_os;
/* Some possible outputs:
Linux localhost 2.4.21-0.13mdk #1 Fri Mar 15:08:06 EST 2003 i686
Linux
Fre EBSD localhost 3.2-release #15: Mon Dec 08:46:02 GMT 2001
FreeBSD
Windows NT XN1 5.1 build 2600
WINNT br>*/
if (Strtoupper (substr (php_os, 0, 3)) = = = ' WIN ') {
    echo ' is a server using windows! ';
} else {
    echo ' is a server not using windows! ';
}
?>

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.