best way to specify path to a file in a $variable?

From: Danny Anderson (danderson_at_dfisystems.com)
Date: 12/30/03


Date: Tue, 30 Dec 2003 09:15:19 -0500
To:  php-general@lists.php.net

Hola, PHP folk-

I am using

$page_title="some page title here";
require('header.inc');

to include a common header for all my pages. I am using $page_title so
I can have unique names for the different pages.

//---header.inc
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
   <head>
     <title><?php echo $page_title; ?></title>
     <link rel=style*** href="./some.css" type="text/css">
   </head>
<body>
...

I want to be able to also define the path to the CSS file. For
instance, some pages will have the CSS in the same directory, so that
part would read

"./my.css"

If the page is located in a subdirectory, the path would then be

"../my.css"

I would like to use a php variable where I can define the path the same
way as the $page_title works. I have tried some experiments with a
$path_to_css variable, but I have not had much success. I think part of
the problem is that I might be stumbling over escaping everything properly.

Is there a better way to do what I am trying to do?

Thanks,
Danny


Quantcast