It's a conceptual question. What's the best way to inlude assets like CSS, Javascript to HTML page.. I'm implementing my own MVC framwork. Application directroy structer is
index.php
controllers
c1.php
c2.php
...
views
v1.php
v2.php
...
scripts
s1.js
s2.js
...
styles
style1.css
style2.css
...
As you can see, all request come through index.php and then I find the right control to handle it.. Controller process some business logic then include a view file..
In view file i need to give an absolute path to all css and java script like this ;
<link rel="stylesheet" type="text/css" href="<?php echo APPROOT; ?>/styles/master.css" />'
<script type="text/javascript" src="<?php echo APPROOT; ?>/scripts/jquery-1.6.1.min.js"></script>
APPROOT is a constant which defines directory path for application:
define("APPROOT", "/project1");
I think It's not the best way so how can i improve it?