PHP global functions ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lazypig06@gmail.com

    PHP global functions ?

    Hi everyone !

    I got a question about how to create a universal functions (visible to
    all pages in current directory and sub directories).

    I am trying to create a function that can be called on each page in
    current directory and sub directories without include the file that
    contains this file. Does anybody know how to do this ?

    To make it more specific, Let's say I created a file "temp.php" which
    contains a function "foo( )".
    Now, I'd like to call foo( ) in every new web pages I create in any
    subdirectory without including the file "temp.php".

    I was told that .htaccess can get this job done. However, I don't know
    exactly how this is done using .htaccess ?

    Any help would be appreciated ?

    Thanks,
    Lazy Pig

  • Carl Vondrick

    #2
    Re: PHP global functions ?

    I was told that .htaccess can get this job done. However, I don't know
    exactly how this is done using .htaccess ?
    Just configure it in php.ini. Set auto_append_fil e to wherever your
    function is.

    Carl

    Comment

    • binderup@gmail.com

      #3
      Re: PHP global functions ?

      Just configure it in php.ini. Set auto_append_fil e to wherever your
      function is.
      Well that might not be a good idea if you don't want the functions to
      be available for all virtual hosts (or if you don't have access to the
      php.ini file).

      I prefer to use the .htaccess method:
      php_value auto_prepend_fi le /full/path/to/script.php

      Comment

      • lazypig06@gmail.com

        #4
        Re: PHP global functions ?

        Hi guys!

        Thank you for your response. If you gonna use .htaccess to this this,
        how would you go about to do that ?
        I've searched many sites, but none of the sites I found has specific
        information about this stuff.

        Thanks,
        Lazy Pig

        binderup@gmail. com wrote:
        Just configure it in php.ini. Set auto_append_fil e to wherever your
        function is.
        >
        Well that might not be a good idea if you don't want the functions to
        be available for all virtual hosts (or if you don't have access to the
        php.ini file).
        >
        I prefer to use the .htaccess method:
        php_value auto_prepend_fi le /full/path/to/script.php

        Comment

        • Rik

          #5
          Re: PHP global functions ?

          lazypig06@gmail .com wrote:
          binderup@gmail. com wrote:
          >>Just configure it in php.ini. Set auto_append_fil e to wherever your
          >>function is.
          >>
          >Well that might not be a good idea if you don't want the functions to
          >be available for all virtual hosts (or if you don't have access to
          >the php.ini file).
          >>
          >I prefer to use the .htaccess method:
          >php_value auto_prepend_fi le /full/path/to/script.php
          Thank you for your response. If you gonna use .htaccess to this this,
          how would you go about to do that ?
          I've searched many sites, but none of the sites I found has specific
          information about this stuff.
          Exactly how he said, create an .htaccess file containing:
          php_value auto_prepend_fi le /full/path/to/script.php

          More files/scripts are perfectly possible.

          Grtz,
          --
          Rik Wasmus


          Comment

          • binderup@gmail.com

            #6
            Re: PHP global functions ?

            Rik wrote:
            Exactly how he said, create an .htaccess file containing:
            php_value auto_prepend_fi le /full/path/to/script.php
            There could be a problem with permissions - make sure that the
            ..htaccess file is set to be executable

            /Peter

            Comment

            • Jerry Stuckle

              #7
              Re: PHP global functions ?

              binderup@gmail. com wrote:
              Rik wrote:
              >
              >>Exactly how he said, create an .htaccess file containing:
              >>php_value auto_prepend_fi le /full/path/to/script.php
              >
              >
              There could be a problem with permissions - make sure that the
              .htaccess file is set to be executable
              >
              /Peter
              >
              ..htaccess is not an executable file and should *never* be set that way.
              It only needs to be readable by the Apache process.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...