PHP Includes Tips & Tricks

By Terry

I was recently discussing php includes with an online pal and the various ways I implement them on my websites. I pretty much use them with copyright notices, cut down templates, category specific stuff and other very basic things. After our talk my interest was peaked and I took a quick turn around the net to see what’s out there in terms of php tips.

Found this nice collection of online tutorials:

Website Tips - PHP

Here are my basic FYI php helps:

What is the absolute path

It’s different on every host, but it’s usually …

/home/accountusername/public_html/

Account username is normally what you use to log into your cpanel/hosting account.

Keep your .php files in a seperate directory

This is just personal preference, but I like keeping all my .php files outta the mix and tucked away into their own directory. I’ll create a directory named: includes (for example) and stick all my .php include files in there.

My absolute path would then be:

/home/accountusername/public_html/includes/

PHP files need a .php file extension to work, so if you’re using .html extensions - you’ll run into errors. Here’s what I put into my .htaccess so that I can have the best of both worlds: .html extensions yet php scripts galore

AddType application/x-httpd-php .php .php3 .phtml .html

Never update your copyright year again

Slap this code in your footer section (or wherever you want to put your copyright info):

Copyright © 2004 - 2008 yourwebsite.com

*Change 2004 to the website creation year, and yourwebsite.com to your domain name. If your website is new this year, just delete the 2004 - part and it will only display the current year.

This is slick and you’ll never have to race around on Jan 1st to update your copyright info! I still have to get around to updating this on a few older sites.

Apologies to the php Pros - like I said - pretty basic stuff :lol:

Leave a Reply