Now and then a PHP programmer needs to figure out, if a script runs on a Linux- or Windows server. Of course you can always consult phpinfo() and check the info in the first line next to ‘System’. But for the further processing in scripts the function phpinfo() is not the best candidate.
Happily PHP offers us at least 3 other possibilities to find out:
Possibility No.1:
A windows server will return here usually the value “WINNT”.
Possibility No.2:
With a Windows-Server we get a result like “Windows NT”. You could use this then in a strpos() query like here:
Possibility No.3:
PHP provides for us a constant for the separator used in directories of the server. Windows systems as we know use the separator \ . So you could use this again for a PHP query with the function strpos() :
—-
….I’m quite that these possibilities are not the only ones – further possibilities are very much appreciated
No Comments yet
Be the first to write a comment