Jump to content

[SOLVED] Functions aren't accessible when using a CONSTANT in an include path


btwilkins

Recommended Posts

Got a problem that I'm stuck on. I'm including a file called "page-functions.php". I wanted to use a constant for the path to the file so that I can include it from any directory. When I do that, the functions inside page-functions aren't accessible. If I take the constant out and hard code the path, my functions work. Any help would be appreciated!

 

--- NOT Working ---

settings.php

<?php
define("ROOT_PATH", "http://www.example.com/");
?>

 

page-functions.php

<?php
function get_test() {
echo "testing!";
}
?>

 

index.php

<?php
include ('settings.php');
include (ROOT_PATH . 'includes/page-functions.php');
get_test(); 
?>

 

-- Working --

index.php

<?php
include ('settings.php');
include ('includes/page-functions.php');
get_test(); 
?>

 

Thanks in advance!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.