|
|
| |
1. php includes issue |
|
Reply |
|
|
 r00t0101 | 2009-04-18 19:28:46 |
Hello all,
I was wondering if this could be done. I would like to re-design my site where the files being called on is using global variables instead of using syntax "../" or "../../". I would like use a more readable approach using global variables like $dir_name/file_name instead if possible. I figured this way there will only be one place to update instead of scanning through the whole file doing a search and replace on each item.
Below is a general idea of what I would like. In this example I have four files: a global, header, footer and an index file. The index file includes the global file without a problem however I had problems executing the header and footer files when using variables as seen commented.
Respectively yours,
Rick
<!-- Start testGlobal.php -->
<?
$CFG->root = "http://127.0.0.1/test";
$CFG->headerDir = "$CFG->root/header";
$CFG->footerDir = "$CFG->root/footer";
?>
<!-- End testGlobal.php -->
<!-- Start index.php -->
<?php
include("TestGlobal.php");
?>
<!-- <? echo $CFG->headerDir; ?>/header.php -->
<?php include ("./header/header.php"); ?>
bla bla bla<br><br>
<!-- <? echo $CFG->footerDir; ?>/footer.php -->
<?php include ("./footer/footer.php"); ?>
<!-- End index.php>
<!-- Start header.php -->
<html>
<head>
<title>Hello world</title>
</head>
Header Test Section<br><br>
<body>
</html>
<!-- End header.php -->
<!-- Start footer.php -->
Copyright @ test.com
<!-- End footer.php> |
There are 3 replies in this thread, which are not being displayed. Browsing this forum thread replies is available only to premium subscribers.
Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum. |