Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Include PHP Script on each page automatically?
Old 02-19-2009, 12:53 PM Include PHP Script on each page automatically?
Junior Talker

Posts: 4
Trades: 0
Is it possible to configure something on the server that will 'inject' a PHP script above the <head> area of every page?

I have a new script that needs to be added to each page but I'm trying to avoid having to open each page individually.

This may not be possible but it doesn't hurt to ask the experts.

Thanks for your feedback.
mrixi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-19-2009, 01:45 PM Re: Include PHP Script on each page automatically?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Yep.
Use the auto_prepend_file option of the php configuration.
You can specify a script that should be prepended (ie: included before running the php page asked).
http://www.php.net/manual/en/ini.cor...o-prepend-file

By the way, there is a auto_append_file configuration too, if you want to run it after the page parsing.
Example as in my code (apache virtualhost config):
Code:
...
setEnv LOCATION dev
php_admin_value auto_prepend_file /var/www/webshots/htdocs/libs/prepend/prepend.php
php_admin_value auto_append_file /var/www/webshots/htdocs/libs/append/append.php
...
As I understand the manual, an .htaccess definition should be possible too.
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 02-19-2009 at 01:47 PM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-19-2009, 01:50 PM Re: Include PHP Script on each page automatically?
Junior Talker

Posts: 4
Trades: 0
Very cool! Thanks for the info, tripy
mrixi is offline
Reply With Quote
View Public Profile
 
Old 02-21-2009, 11:28 PM Re: Include PHP Script on each page automatically?
Junior Talker

Posts: 1
Trades: 0
i was wondering the same thing...is this how wordpress is able to load all the configuration files on every page without having include or require lines all over the place?
tefuzz is offline
Reply With Quote
View Public Profile
 
Old 02-22-2009, 10:07 AM Re: Include PHP Script on each page automatically?
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Quote:
Originally Posted by tefuzz View Post
i was wondering the same thing...is this how wordpress is able to load all the configuration files on every page without having include or require lines all over the place?
I think they just include a file which includes a load of other files.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Reply     « Reply to Include PHP Script on each page automatically?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21304 seconds with 12 queries