root directory in php

Solutions on MaxInterview for root directory in php by the best coders in the world

showing results for - "root directory in php"
Daniele
23 Oct 2016
1function getHtmlRootFolder(string $root = '/var/www/') {
2
3    // -- try to use DOCUMENT_ROOT first --
4    $ret = str_replace(' ', '', $_SERVER['DOCUMENT_ROOT']);
5    $ret = rtrim($ret, '/') . '/';
6
7    // -- if doesn't contain root path, find using this file's loc. path --
8    if (!preg_match("#".$root."#", $ret)) {
9      $root = rtrim($root, '/') . '/';
10      $root_arr = explode("/", $root);
11      $pwd_arr = explode("/", getcwd());
12      $ret = $root . $pwd_arr[count($root_arr) - 1];
13    }
14
15    return (preg_match("#".$root."#", $ret)) ? rtrim($ret, '/') . '/' : null;
16}
17
queries leading to this page
php get root directoryhow can i get the directory root in phpget root dir phproot folder phproot path phpphp root folder urlhow to use root directory on phpphp get current root directorysystem root phpget root directory path in phpphp access root directoryopen the root of the folder phphow to reference the root folder in phpwhat is the root directory in a website phpload root folder phproot directory phphow to define root path phphow to get the root path in phphow to go root from any folder in phpphp root pathphp url to root folderphp get root directory pathhow to get thr root folder in phpserver root path in phpphp include from root dirphp rootdirserver root directory phpphp root dirphp localhost root directoryphp root directoryphp root dirroot dir phpget root path using phpphp get project rootdefine root path phphow to finde root of folder in phphow to set a root path in phphow to get the root directory in phphow to open root folder in phpphph to get root directoryphp get root dirphp get root directory of projecthow to get root directory in phpphp root directory pathphp dir rootphp root folderroot dir in phproot directory of php filehow to set root path in phpphp app root folderchange root directory in phproot directory pghpget the root directory in phppath 2fto 2froot phphow to include root folder file in phproot directory path in phpget root directory phpphp get root folderroot folder in phproot in phproot directory dari phpget the root folder in phpphp server root directoryphp root directory of websiteget root location phpget to root directory phproot directory in phpphp get base root directoryhow to access root folder in php exampleget root directory from string phpphp require root directoryset root dir init phphow to get root path in phpget root path in phprun php in current directoryphp directory rootdocument root directory phpphp set root directoryproject root directory phpphp get root directoryphp root directory fileinclude root directory phproot path in phproot folder path phpphp root path directoryphp how to set root directoryroot directory path in phphow to access root folder in phpserver root folder phpphp go to root directoryphp root directory 24 server 5broot directory in php