Graphic Design Forum and Web Design Forum  

Go Back   Graphic Design Forum and Web Design Forum »Web Design Forum »Programming Forum

Notices

Programming Forum Web and Software Programming Forum - Java, PHP, SQL etc.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-01-2007, 07:44 AM
Andy's Avatar
Admin
 
Join Date: Jan 2007
Location: Berkshire, UK
Gender: Male
Posts: 235
Default PHP Includes

When designing a web site the first thing you should think about is how easy do you want future edits to be..

Well with PHP you can speed up many processes that you may do countless times..

first thing is create a config.php
PHP Code:
<?php
$companyname
="Test Ltd";
$companyemail=me@meme.co.uk;
$footer="Copyright 2007 Test Ltd";
$cssdir="css/site.css";
?>
with a basic config file you can add many more types of fields.. then on top of every page you edit add this to the very first line in your code. before the html tags etc..!

PHP Code:
<?php include("config.php"); ?>
Now anywhere you want to publish your variable do this

PHP Code:
<?php echo $companyname?>
Dont forget all files must be PHP extensions.
I have found this method to save me a lot of time.. it can be used for anything and dont forget that any config.php cannot be opened in another page. if you navigate to this config file it will be blank! hiding your details!!

Its also a good idea to do includes for your menus etc.. so a simple include tag with the pure html or css to that menu no html needed in the include and you can change all pages with the same menu from one file.

Enjoy
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote

  #2 (permalink)  
Old 23-01-2007, 05:03 PM
Junior Member
 
Join Date: Jan 2007
Location: Switzerland
Posts: 49
Default

good information for those in need, however one thing I noticed.

Quote:
Dont forget all files must be PHP extensions.
You can use other extensions, but using .php extensions means the browser will interpret it as a server side script and now print out the code in a page, but you can include .html, .htm, .txt or anyother type of file

What Im saying is for example say you have a file at: yoursite.com/welcome.html

and that includes a file called: title.htm

now in the title.htm file you have some things you might now want to show, then you should use title.php.

Anyone who then types: yoursite.com/title.htm can see its contents whether it be code or not.

However, if that person types: yoursite.com/title.php, will only see stuff that is printed to the browser (stuff with for example) but other stuff wont show up

dont know if this was very clear :) but hope it was.
__________________
Evolving with style // www.benshu.ch
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #3 (permalink)  
Old 25-01-2007, 12:24 PM
Andy's Avatar
Admin
 
Join Date: Jan 2007
Location: Berkshire, UK
Gender: Male
Posts: 235
Default

maybe you didnt get the point.. its for dynamic content so that you can edit few lines of code on seperate pages within one file. so php extensions is needed or it wouldnt work. unless (doubt it) you have your server setup to use .htaccess files to modify mime type
__________________
C# Developer, Passionate Nikon D80 Photographer, Motorcycle Lover
ProtoIP.com
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
  #4 (permalink)  
Old 25-01-2007, 05:15 PM
Junior Member
 
Join Date: Jan 2007
Location: Switzerland
Posts: 49
Default

hehe, I do have .htaccess file so I can use .htm, .html and it get parsed as php :), sorry.

But my point about not having to use .php extension is still true, if its not dynamic or php content and you dont have .htaccess modified.

I often use a template such as the following:

Code:




although I tend to use .php extension for security :), could be an html file, a txt file that it included.

makes it easier to make quick changes to a whole site especially with many pages.
__________________
Evolving with style // www.benshu.ch

Last edited by bluesage; 25-01-2007 at 05:25 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati Share This Article & VoteReddit! Wong this Post!Stumble this Post!RSS Share on FacebookForum Netvibes Page
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
includes in an array? PR Design Programming Forum 11 18-10-2007 11:19 AM


All times are GMT. The time now is 10:52 PM.



Estetica Design Forum's Privacy Policy
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0