Original Post
Hi, I'm new to PHP and web development in general.
In a PHP file, I have this:
Then lower down, I do this:
The PHP file with that code is located at:
mywebsite.com/wp-content/themes/jamintheme/functions.php
The files I'm trying to include are located at:
mywebsite.com/wp-content/jg-common/variables.php
and
mywebsite.com/wp-content/jg-subsite/variables.php
The error message I'm getting is:
[color=#008000]Warning: include(../../jg-common/variables.php) [function.include]: failed to open stream: No such file or directory in /home/host-user/public_html/mywebsite.com/wp-content/themes/jamintheme/functions.php on line 11
What am I doing wrong?
I thought if I use '.' or '..' to start off the path, it's relative to the current directory.
In a PHP file, I have this:
$jg_globalVariables = array();
$jg_globalVariables['common_folder'] = '../../jg-common';
$jg_globalVariables['subsite_folder'] = '../../jg-subsite';
function jg_GetGlobalVar($key)
{
global $jg_globalVariables;
return (isset($jg_globalVariables[$key])) ? $jg_globalVariables[$key] : '';
}Then lower down, I do this:
include jg_GetGlobalVar('common_folder') . '/variables.php';
include jg_GetGlobalVar('subsite_folder') . '/variables.php';The PHP file with that code is located at:
mywebsite.com/wp-content/themes/jamintheme/functions.php
The files I'm trying to include are located at:
mywebsite.com/wp-content/jg-common/variables.php
and
mywebsite.com/wp-content/jg-subsite/variables.php
The error message I'm getting is:
[color=#008000]Warning: include(../../jg-common/variables.php) [function.include]: failed to open stream: No such file or directory in /home/host-user/public_html/mywebsite.com/wp-content/themes/jamintheme/functions.php on line 11
What am I doing wrong?
I thought if I use '.' or '..' to start off the path, it's relative to the current directory.