Jump to content

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


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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.