Set Up root path constant

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
leandrojunior7
Forum Newbie
Posts: 4
Joined: Wed Dec 14, 2011 4:13 pm

Set Up root path constant

Post by leandrojunior7 »

Hello, I am studying the code of phpBB, virtually all of the files have this code at the beginning of the file, my question is as follows:

How the php know that PHPBB_ROOT_PATH refers to the root directory where the files and directories are on the forum.
It seems to me that is a constant set to root, but where is it defined?, for example I wanted to change the PHPBB_ROOT_PATH to PHPBB_HOME

Code: Select all


define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);


User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Set Up root path constant

Post by Christopher »

Probably these files are included by one of the scripts accessed in URLs. That variable it probably in the configuration file.
(#10850)
leandrojunior7
Forum Newbie
Posts: 4
Joined: Wed Dec 14, 2011 4:13 pm

Re: Set Up root path constant

Post by leandrojunior7 »

The configuration file called config.php its blank. its weird.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Set Up root path constant

Post by Christopher »

It sounds like the installation script was not able to write the config.php file. If you search for "phpBB configuration file" you can get information about how to fix this.
(#10850)
leandrojunior7
Forum Newbie
Posts: 4
Joined: Wed Dec 14, 2011 4:13 pm

Re: Set Up root path constant

Post by leandrojunior7 »

So, the conditional always returns false cause its not defined any constant called PHPBB_ROOT_PATH.

Code: Select all

<?
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
?>
Is it tha same thing following?

Code: Select all

<?
$phpbb_root_path = './';

?>

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Set Up root path constant

Post by Christopher »

Yes.
(#10850)
leandrojunior7
Forum Newbie
Posts: 4
Joined: Wed Dec 14, 2011 4:13 pm

Re: Set Up root path constant

Post by leandrojunior7 »

THANKS ! :)
Post Reply