Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP global functions ?

lazypig06@gmail.com
Guest
 
Posts: n/a
#1: Aug 8 '06
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
Guest
 
Posts: n/a
#2: Aug 8 '06

re: PHP global functions ?


Quote:
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_file to wherever your
function is.

Carl
binderup@gmail.com
Guest
 
Posts: n/a
#3: Aug 9 '06

re: PHP global functions ?


Just configure it in php.ini. Set auto_append_file to wherever your
Quote:
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_file /full/path/to/script.php

lazypig06@gmail.com
Guest
 
Posts: n/a
#4: Aug 10 '06

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:
Quote:
Quote:
Just configure it in php.ini. Set auto_append_file 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_file /full/path/to/script.php
Rik
Guest
 
Posts: n/a
#5: Aug 10 '06

re: PHP global functions ?


lazypig06@gmail.com wrote:
Quote:
binderup@gmail.com wrote:
Quote:
Quote:
>>Just configure it in php.ini. Set auto_append_file 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_file /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_file /full/path/to/script.php

More files/scripts are perfectly possible.

Grtz,
--
Rik Wasmus


binderup@gmail.com
Guest
 
Posts: n/a
#6: Aug 19 '06

re: PHP global functions ?


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

/Peter

Jerry Stuckle
Guest
 
Posts: n/a
#7: Aug 19 '06

re: PHP global functions ?


binderup@gmail.com wrote:
Quote:
Rik wrote:
>
Quote:
>>Exactly how he said, create an .htaccess file containing:
>>php_value auto_prepend_file /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@attglobal.net
==================
Closed Thread