define root path php
<body>
<?php
define('ROOT_PATH', dirname(__DIR__).'/');
include ROOT_PATH.'header.php';
include ROOT_PATH.'main.php';
include ROOT_PATH.'footer.php';
?>
</body>
define root path php
<body>
<?php
define('ROOT_PATH', dirname(__DIR__).'/');
include ROOT_PATH.'header.php';
include ROOT_PATH.'main.php';
include ROOT_PATH.'footer.php';
?>
</body>
root directory in php
function getHtmlRootFolder(string $root = '/var/www/') {
// -- try to use DOCUMENT_ROOT first --
$ret = str_replace(' ', '', $_SERVER['DOCUMENT_ROOT']);
$ret = rtrim($ret, '/') . '/';
// -- if doesn't contain root path, find using this file's loc. path --
if (!preg_match("#".$root."#", $ret)) {
$root = rtrim($root, '/') . '/';
$root_arr = explode("/", $root);
$pwd_arr = explode("/", getcwd());
$ret = $root . $pwd_arr[count($root_arr) - 1];
}
return (preg_match("#".$root."#", $ret)) ? rtrim($ret, '/') . '/' : null;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us