Hi all
I'm still learning PHP, I want to know if anyone can explain to me how to create a library of functions etc that I may create. I know that you can have a file called 'lib' for example and then pages call the functions from these files when needed before the header of the page is sent.
I hope someone can shed some light on this for me.
Thanks in advance
DW
Creating libraries for processing before header sent
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Creating libraries for processing before header sent
You don't need to get your PHP scripts any special names, such as 'lib', they can be named anything. The term "headers sent" refers to the fact that if script outputs anything (even a space character) then PHP will first sent any HTTP headers it sends by default or that you have added. So you cannot sent output and then call the header() function because the output cause the HTTP headers to already be sent.
Just put your PHP code before output occurs, or gather output in a variable and echo it at the end of the script.
Just put your PHP code before output occurs, or gather output in a variable and echo it at the end of the script.
(#10850)