Jump to content

Prepend file so I can include HTTP headers?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
FireGator

FireGator

    Learning Programmer

  • Members
  • PipPipPip
  • 37 posts
I am in a situation where I have quite a few files in my project but wish to add just a handful of things beforehand.

I can technically add requires to each file at the beginning but this would be a long process, and I would need to point them to different level directories for each one.

Is there a method to force PHP to load a file along (before) each execution of another file?
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]
>++++++++[<++++>-] <.>+++++++++++

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
There is a method right of the bat for you that the PHP engine provides, It is the option auto_prepend_file. It can be applied to vhosts, php.ini or .htaccess level configurations:
format: auto_prepend_file <path>
ex: php_value auto_prepend_file $HOME/public_html/prependheaders.php

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
FireGator

FireGator

    Learning Programmer

  • Members
  • PipPipPip
  • 37 posts

Nullw0rm said:

There is a method right of the bat for you that the PHP engine provides, It is the option auto_prepend_file. It can be applied to vhosts, php.ini or .htaccess level configurations:
format: auto_prepend_file <path>

ex: php_value auto_prepend_file $HOME/public_html/appendheaders.php

Ha! This looks exactly right, thanks. It was more for a security thing, it was the best way.
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]
>++++++++[<++++>-] <.>+++++++++++