Stop worrying about relative path by just using a base path set as a configuration so you are not constantly juggling relative locations. For example, in your main config file, you can define a base path like this:
$BASE_PATH = '/the/path/to/the/codebase/';
If you don’t know the base path to your files, then place this line at the top of your PHP code:
echo "Your path is: " . realpath(dirname(__FILE__)) . "<br />";
And load that page. Somewhere near the top should be a line that reads:
Your path is: /the/path/to/the/codebase/
/the/path/to/the/codebase/ will be your actual file path, but that will be your base path. Then just set
$BASE_PATH to that value.
Then when you do an
require, the syntax would be:
require($BASE_PATH . '/cis130/textfiles/php/variables.php');
The benefit of this is no matter how deeply nested your codebase becomes, you will always be anchored to the value of
$BASE_PATH. And your life will be made tons easier thanks to not having to worry about relative path issues.
require_once($BASE_PATH . '/cis130/textfiles/php/variables.php');