开发者

Finding out the OS my PHP script is run on [duplicate]

This question 开发者_如何学JAVAalready has answers here: Closed 11 years ago.

Possible Duplicate:

How to get the OS on which PHP is running?

I need my script to be able to recognize whether it's being run on a Windows or on a Linux system so it can behave accordingly. How do I do that?

EDIT: I need a definite way of doing that, that has no risk of recognizing the wrong OS.


php_uname and/or the PHP_OS constant will tell you. See the examples here: http://www.php.net/manual/en/function.php-uname.php


if (PHP_OS == 'Linux') echo 'Linux os!'


predefined constant: PHP_OS ........


Have you looked at the php_uname() function?

http://us.php.net/manual/en/function.php-uname.php


Here is the second link if I google 'os php':


Note that anything that comes from the browser to your code can be spoofed, so it's not 'definite'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜