config.inc.php:
<?php
define ('SITE_NAME', 'iLiKEiLiKE');
?>
page.php:
<?php
class Page {
public $page_title;
public $script;
// Class constructor
public function __construct($page_title, $script = '', $contents = '')
{
// Include configuration file
include('../config.inc.php');
}
}
?>
index.php:
<?php
include('classes/page.php');
$contents = " <p>Welcome to ".SITE_NAME.".</p>";
$page = new Page('Home', '<script></script>', $contents);
if(defined('SITE_NAME'))
{
echo "it is defined";
}
else
{
echo "it is not defined";
}
?>
There is a lot of unnecessary stuff excluded. Bascially, index.php calls the page.php class and the constructor for that class includes config.inc.php. I have the test to see if the constant is defined and it evaluates to "it is defined". So...I'm baffled.