A way to do this is to use require
So you have, in all your pages a line, at the top of your page that reads something like:
require($_SERVER['DOCUMENT_ROOT'].'/includes/security_required.inc');
require($_SERVER['DOCUMENT_ROOT'].'/includes/database.inc');
Then you have those INCLUDE files at the beginning of all your scripts and there is no need to duplicate. Read a bit about them, you can do pretty neat things. Hope this helped.