Code Example #1 – Per File Execution Testing

In my projects i often come across or up with cute pieces of code that i think may be interesting to others. Instead of hoarding i will be posting them (possibly in sub pieces) so you can take part in the fun.

Todays Fragment: Per File Execution Testing

You can use this piece of code to test the file being executed and perform unit testing or output debug information as necessary. It can also, as is being used here, be used to redirect the user away from executing this page.


I dont think the exit is entirely necessary, but it may be dependent upon the server’s configuration.