...Beauty, cleaning, DIY tips and more - free to join!
   Login   Contact us   Site map   Puzzle Club   Ask a question    Newsletter

How To Include A File In PHP

Computing : Learning PHP

One of the best things about languages like PHP is the easy ability to include code across several files.

Thus if you have a top or left hand menu you can define it once likes a template and then simply include across the site.

This then makes it really easy to change should you need to across the site.

Simply place the code to be included in a file and if it contains PHP ensure that you have the PHP code markers at the start and end of the file.

Then to include simply add this to the file that includes it:
include ("myinclude.php");

Note that if you want to be sure that you don't include the same file more than once, then just use:
include_once("myinclude.php");

if already included subsequent files will realise this and ignore the additional calls to include that file.


Profile image!
By: Stephen

  More about PHP and mySQL

  Reply to How To Include A File In PHP

  Receive Our Newsletter

  Send to friend

PHP and mySQL picture



Questions about PHP and mySQL:

Ask question

More Articles:
How to stop applications taking over on XP
How to make real money from podcasting
How to get warnings in Perl