Hi!
I'm a newbie with PHP, and I'm creating my web. The problem is that I need the home path of the server to call my functions, independently where is the call to them. Anyone can help me?
Thank you!
Absolute path
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
There are many ways to achieve that. Here are a couple:
Or
Code: Select all
define('BASE_DIR', '/path/to/my/files/');
include BASE_DIR . 'myscript.php';Code: Select all
define('BASE_DIR', '/path/to/my/files/');
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . BASE_DIR);
include 'myscript.php';(#10850)
or use both ? 
(in which BASEURL is not an absolute server path of course)
Or is that stupid?
Code: Select all
$path = $_SERVER['DOCUMENT_ROOT'] . BASEURL;
header('Location: $path');Or is that stupid?
Thank you to all
Thank you, for all the replies 