I want to add an include to all of my pages on my site. The file i want to include is called code.php which just simply contains javascript for google analytics. My Question is: there is no PHP code in code.php (not even php tags around the javascript) so is it ok to call the include file (code.php) a .php file even though there is no php code it at all I just out this into all of my pages where i wanted to include the JS code <?php include("code.php");?> PHP: Thanks in advance
yep, it is definitely allowed, php is a very loose language and you can even include a php file that only had html on it
I do since long exactly the same - to (PHP)-SSI my adsense into each page - its an ideal way to create a highly sophisticated system of adsense channels to optimize your ads, to change ads by changing a few files only without touching the pages, by adding banners ... almost like you would using an adserver. but I gave the files to include a difference file-extension .tpl to make my life easier - but any other extension may work as well. php looks like code, tpl or other extensions is for text - it makes YOUR life easier later on to see at a glance from file extensions what content is where. hence basically your .php also should work as well one last point - I just solved last night - each such included adsense file will create a local server call = entry in your log file. with high traffic sites a lot of additional HDD-writing ( in my case some 120k/day log lines just for such) access that you may omit with proper code from being written to log files for better clarity of log files. since you do such procedure, it means you most likely have a bigger site and the SSI saves you time and work - hence if you have your own dedicated server now or later you may omit logging local server requests for such file requests as well. btw: my adsense SSI system was the beginning of serious adsense optimization leading to a near double in $ earlier this year. take your time when choosing the correct page placements of your SSI - your $ will reward you.
You may also want to consider php's auto_prepend_file method, this effectively includes a file at the beginning of every page handled by the php engine. It saves having to add the include code into every php page on your site. There is an example of how to use it in my blog... http://www.imblogingit.com/2007/11/27/pulsating/google-301-redirect-for-multiple-domains-the-php-answer/