I’ve having to clean up/maintain some old php site files. There are a number of main php pages which include() other php files based on rules. A number of these includes have lines such as below in them:
<link href="css/styles.css" rel="stylesheet" type="text/css">
<script language="javascript" src="js/functions.js"></script>
Some of the time after the php page has been built, these external files are included more than once in the same page.
It’s not just a simple case of removing these external file links from the php includes, as sometimes where the php include is placed, it is the only occurrence.
Is there some kind of checking, either by php or js to avoid multiple occurrences of external files?
Thanks 🙂
As an easy hack, add those CSS and JS files into a PHP file, and put a require_once to the PHP file. That way the file will only be included if it hasn’t been included yet.