Srv OS compatibility and $_ENV

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • awebguynow

    Srv OS compatibility and $_ENV

    I'm running PHP on my local WinXP box, but will host on *nix Srv.

    So I started to use and OS detect, something like (psuedo-code):
    if ( strpos($_ENV['OS'], "Win") === false ) { *nix } else { Win }

    but its not working right, and I wondered why.
    My OS looks to be set, as shown by WinXPset
    ditto for output from phpinfo()
    But the $_ENV global, looks like an empty array Array ( )
    whats the story ?

    Of course I've the incompatible versions of Apache/PHP: A2.2x and
    php5.1.x
    patched with php5apache2_2.d ll
    ( thats the only reason I didn't cry after installing 5.1.4 and then
    having 5.1.5 come out the next day ) It makes you wonder, what part
    of 5.1.x am I really using, if any

    my settings from phpinfo():
    Apache Version Apache/2.2.3 (Win32) PHP/5.2.0RC2-dev

  • Alvaro G. Vicario

    #2
    Re: Srv OS compatibility and $_ENV

    *** awebguynow escribió/wrote (22 Aug 2006 13:36:43 -0700):
    I'm running PHP on my local WinXP box, but will host on *nix Srv.
    >
    So I started to use and OS detect, something like (psuedo-code):
    if ( strpos($_ENV['OS'], "Win") === false ) { *nix } else { Win }
    This can't be a good idea... I presume you need to use certain OS-dependent
    feature. Why don't you just check for that specific feature?

    Anyway, in the "Predefined constants" chapter I see PHP stores the value
    for you so you don't depend on environmental variables:

    Core Predefined Constants

    These constants are defined by the PHP core. This includes PHP, the Zend
    engine, and SAPI modules.

    PHP_OS (string)

    But the $_ENV global, looks like an empty array Array ( )
    whats the story ?
    Check the variables_order directive in "php.ini". There's also a comment
    about it in the file:

    ; - variables_order = "GPCS" [Performance]
    ; The environment variables are not hashed into the $_ENV. To access
    ; environment variables, you can use getenv() instead.





    --
    -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    ++ Mi sitio sobre programación web: http://bits.demogracia.com
    +- Mi web de humor con rayos UVA: http://www.demogracia.com
    --

    Comment

    • awebguynow

      #3
      Re: Srv OS compatibility and $_ENV

      I appreciate your comments and now know the skinny on this subject. I
      can use
      getenv()
      PHP_OS
      php_uname()

      I'm just very suprised that phpinfo() would report each ENV var, but
      these would not go into $_ENV
      Also, I did not see PHP_OS mentioned in the manual, but it appears to
      be a Standard part of the lang, and I saw quite a few references
      online.

      Comment

      • Alvaro G. Vicario

        #4
        Re: Srv OS compatibility and $_ENV

        *** awebguynow escribió/wrote (24 Aug 2006 13:56:59 -0700):
        Also, I did not see PHP_OS mentioned in the manual, but it appears to
        be a Standard part of the lang, and I saw quite a few references
        online.
        It can be found in:

        Main : Appendixes : List of Reserved Words : Predefined Constants

        I have the extended CHM version and I just typed "pred" in the index input
        box ;-)


        --
        -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
        ++ Mi sitio sobre programación web: http://bits.demogracia.com
        +- Mi web de humor con rayos UVA: http://www.demogracia.com
        --

        Comment

        Working...