You are here: Re: Detecting Windows or *ix? « PHP Programming Language « IT news, forums, messages
Re: Detecting Windows or *ix?

Posted by Schroeder, AJ on 07/05/07 22:05

Oliver Grδtz wrote:
> Schroeder, AJ schrieb:
>> Hello group,
>>
>> I have a few PHP scripts that poll switches and routers via SNMP.
>> Depending on the user, the scripts can be run from either Windows XP
>> or *ix (FreeBSD, Redhat, etc)
>>
>> I am beginning to implement syslog() and openlog() in my scripts and
>> there are some suddle differences in how PHP logs to event viewer in
>> Windows and syslog in everything else. About the most reliable
>> method I have found in detecting Windows is a simple check to see if
>> $_SERVER['OS'] is defined, which returns "Windows_NT". On Redhat it
>> doesn't come back as defined at all, so that makes the code easy.
>>
>> I'm sure I am not the first one to attempt this, can anyone else
>> share their experiences with this and maybe offer a better way other
>> than checking for a predefined constant?
>
> Why? What's the problema with the constant PHP_OS ?
>
> OLLi

No problem... I guess I didn't know about it since I always ran the scripts
from Redhat.

I am using a the constants PHP_OS and DIRECTORY_SEPARATOR to check and see
what os the script is running from.

I also didn't know about php_uname(), so I am using that for something in my
scripts, too.

Thank you to all who responded, the suggestions really helped!

AJ Schroeder

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация