I've got a site that I'm doing in php using several includes that are shared by pages in various folders so I've got to use a full path to the links, graphics, etc.
We're developing on a test location on the client's server and will eventually migrate to the production area.
Is there an easy way to declare a php variable in the first include to set the path for all the graphics, links, etc.?
For example, I've got index.php and contact/index.php which call:
andCode:<?php include("header.php") ?>
respectively...Code:<?php include("../header.php") ?>
Now, in header.php I've got:
andCode:<link rel="stylesheet" type="text/css" href="http://clientsite.com/css/style.css" />
andCode:<script type="text/javascript" src="http://clientsite.com/js/jquery.js"></script>
Is there a way (in header.php) to do something like:Code:<a href="http://clientsite.com/page.html"><img src="http://clientsite.com/images/image.jpg" alt="1" border="0" /></a>
If that will work, how would I write the above calls? Would I just have to wrap the php tags around them, or do I need to use echo?? Something like:Code:<?php $root= "http://clientsite.com/"; ?>
Haven't done this with php before so I'm not sure what the best practice is and what the code details are...Code:<?php <link rel="stylesheet" type="text/css" href=$root.'/css/style.css' /> ?>
THANKS!!


Reply With Quote