apache passing value to php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • go-tard

    apache passing value to php

    Hello,

    I'm wondering if there's a way to pass a value from apache to php
    through httpd.conf. I've noticed that php settings can be changed
    using php_value. Is there a way to send a value that is not one of the
    settings to php in this way? Something like:

    php_value my_dogs_name "sparky"

    Then $my_dogs_name becomes globally accessible to all scripts on the
    server. Specifically, I'd like to keep the name of the mysql db name
    in the portion of httpd.conf associated with the virtual server that
    uses it. I don't think I can use any of the php_value mysql.* settings
    because I'm using PEAR DB. Any ideas? Thanks!
  • Chung Leong

    #2
    Re: apache passing value to php

    See http://www.phpfreaks.com/apache_manu...d/mod_env.html

    The value set would be in the $_ENV array.

    Uzytkownik "go-tard" <go_tard@yahoo. ca> napisal w wiadomosci
    news:2ee55776.0 403221108.4e179 f2a@posting.goo gle.com...[color=blue]
    > Hello,
    >
    > I'm wondering if there's a way to pass a value from apache to php
    > through httpd.conf. I've noticed that php settings can be changed
    > using php_value. Is there a way to send a value that is not one of the
    > settings to php in this way? Something like:
    >
    > php_value my_dogs_name "sparky"
    >
    > Then $my_dogs_name becomes globally accessible to all scripts on the
    > server. Specifically, I'd like to keep the name of the mysql db name
    > in the portion of httpd.conf associated with the virtual server that
    > uses it. I don't think I can use any of the php_value mysql.* settings
    > because I'm using PEAR DB. Any ideas? Thanks![/color]


    Comment

    • Andy Hassall

      #3
      Re: apache passing value to php

      On Mon, 22 Mar 2004 14:48:38 -0500, "Chung Leong" <chernyshevsky@ hotmail.com>
      wrote:
      [color=blue]
      >Uzytkownik "go-tard" <go_tard@yahoo. ca> napisal w wiadomosci
      >news:2ee55776. 0403221108.4e17 9f2a@posting.go ogle.com...[color=green]
      >>
      >> I'm wondering if there's a way to pass a value from apache to php
      >> through httpd.conf. I've noticed that php settings can be changed
      >> using php_value. Is there a way to send a value that is not one of the
      >> settings to php in this way? Something like:
      >>
      >> php_value my_dogs_name "sparky"
      >>
      >> Then $my_dogs_name becomes globally accessible to all scripts on the
      >> server. Specifically, I'd like to keep the name of the mysql db name
      >> in the portion of httpd.conf associated with the virtual server that
      >> uses it. I don't think I can use any of the php_value mysql.* settings
      >> because I'm using PEAR DB. Any ideas? Thanks![/color]
      >
      >See http://www.phpfreaks.com/apache_manu...d/mod_env.html
      >
      >The value set would be in the $_ENV array.[/color]

      Actually, having just tried it, it ends up in the $_SERVER array.

      Possibly because it only adds it to the environment for CGI scripts and not
      modules (which run inside the Apache process rather than as a subprocess). But
      there appears to be some mechanism in place that passes values from SetEnv to
      $_SERVER when running PHP as an Apache module.
      --
      Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
      http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

      Comment

      • Chung Leong

        #4
        Re: apache passing value to php

        Uzytkownik "Andy Hassall" <andy@andyh.co. uk> napisal w wiadomosci
        news:ucju50hgld p4ne1808eltb25o am5aqo46e@4ax.c om...[color=blue][color=green]
        > >See http://www.phpfreaks.com/apache_manu...d/mod_env.html
        > >
        > >The value set would be in the $_ENV array.[/color]
        >
        > Actually, having just tried it, it ends up in the $_SERVER array.
        >
        > Possibly because it only adds it to the environment for CGI scripts and[/color]
        not[color=blue]
        > modules (which run inside the Apache process rather than as a subprocess).[/color]
        But[color=blue]
        > there appears to be some mechanism in place that passes values from SetEnv[/color]
        to[color=blue]
        > $_SERVER when running PHP as an Apache module.[/color]

        Thanks for the correction. That make sense, since on some platforms (Win32
        namely) Apache runs as a single process.


        Comment

        • go-tard

          #5
          Re: apache passing value to php

          Thanks very much for your help. I've tried this and haven't found the
          value available in either $_ENV or $_SERVER. I think I'm running php
          as an apache module. Is there something I need to do to get this value
          put into $_SERVER. Thanks.

          "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message news:<V7OdncAua 6jzMcLdRVn-jw@comcast.com> ...[color=blue]
          > Uzytkownik "Andy Hassall" <andy@andyh.co. uk> napisal w wiadomosci
          > news:ucju50hgld p4ne1808eltb25o am5aqo46e@4ax.c om...[color=green][color=darkred]
          > > >See http://www.phpfreaks.com/apache_manu...d/mod_env.html
          > > >
          > > >The value set would be in the $_ENV array.[/color]
          > >
          > > Actually, having just tried it, it ends up in the $_SERVER array.
          > >
          > > Possibly because it only adds it to the environment for CGI scripts and[/color]
          > not[color=green]
          > > modules (which run inside the Apache process rather than as a subprocess).[/color]
          > But[color=green]
          > > there appears to be some mechanism in place that passes values from SetEnv[/color]
          > to[color=green]
          > > $_SERVER when running PHP as an Apache module.[/color]
          >
          > Thanks for the correction. That make sense, since on some platforms (Win32
          > namely) Apache runs as a single process.[/color]

          Comment

          • Sandman

            #6
            Re: apache passing value to php

            In article <2ee55776.04032 21108.4e179f2a@ posting.google. com>,
            go_tard@yahoo.c a (go-tard) wrote:
            [color=blue]
            > Hello,
            >
            > I'm wondering if there's a way to pass a value from apache to php
            > through httpd.conf. I've noticed that php settings can be changed
            > using php_value. Is there a way to send a value that is not one of the
            > settings to php in this way? Something like:
            >
            > php_value my_dogs_name "sparky"
            >
            > Then $my_dogs_name becomes globally accessible to all scripts on the
            > server. Specifically, I'd like to keep the name of the mysql db name
            > in the portion of httpd.conf associated with the virtual server that
            > uses it. I don't think I can use any of the php_value mysql.* settings
            > because I'm using PEAR DB. Any ideas? Thanks![/color]

            SetEnv my_dogs_name "sparky"


            print $_SERVER["my_dogs_na me"];

            --
            Sandman[.net]

            Comment

            Working...