Press "Enter" to skip to content

Month: March 2008

PHP: Avoiding “Headers already sent by…” errors

Just a quick post inspired by Techgirl, here’s how to avoid the annoying PHP errors “Headers already sent by…” when working with multiple files.

Basically, a PHP script usually looks like:

<?php
include "my.lib.php";
include "otherstuff.php";
....
?>

however, if my.lib.php (for example) looks like:

<?php
....
...
?>


(do you see the hidden “new line at the end”), you’ll get the “Warning: Cannot modify header information – headers already sent by (output started at my.lib.php:6) in index.php on line 2? error.

So how do you simpley avoid this? Easy! Omit the closing ?> from the library/include files. My.lib.php now looks like:

<?php
....
...

and the problem is solved.

Simple, quick solution which is worth remembering!

Personal: Bring Bring… Sorry, that person is Engaged

As you all should be aware, today being February 30th March 1st, means that yesterday was Feburary 29th aka Ladies Day: the one day of the year (technically 4 years) where a women can, traditionally, ask her boyfriend/partner to marry her.

I think you know what’s coming.

Yep, the gorgeous Katy got down on one knee (although I had to help her up again) and asked for my hand in marriage. After less than a minute (most of which was trying to choke back the tears), I gave in to her and said yes (given the choice of giving my soul to her or giving her a pair of silk gloves in compensation, well, the soul was cheaper 😀 ).

So, after 1.75 years of knowing each other and 1.5 years of dating, we now have official names for each other instead of just generic “my partner”, “my other half” and “thingy”. I do love her dearly, but we haven’t set a date yet (she wasn’t sure until yesterday whether she was just going to ask me to be her fiancé or do what she did do and ask “Do you want to marry me?”) but contributions are welcome towards the mawwage.